diff --git a/src/sharding/ShardClientUtil.js b/src/sharding/ShardClientUtil.js index 044d8ab35818..e5b40b5b779a 100644 --- a/src/sharding/ShardClientUtil.js +++ b/src/sharding/ShardClientUtil.js @@ -200,13 +200,14 @@ class ShardClientUtil { */ _respond(type, message) { this.send(message).catch(err => { - err.message = `Error when sending ${type} response to master process: ${err.message}`; + const error = new Error(`Error when sending ${type} response to master process: ${err.message}`); + error.stack = err.stack; /** * Emitted when the client encounters an error. * @event Client#error * @param {Error} error The error encountered */ - this.client.emit(Events.ERROR, err); + this.client.emit(Events.ERROR, error); }); }