From d1c5b6fe9e18b532ad69ed4bd82e1874a6dff4df Mon Sep 17 00:00:00 2001 From: meister03 <69507874+meister03@users.noreply.github.com> Date: Mon, 7 Jun 2021 14:09:23 +0200 Subject: [PATCH] fix(ShardingManager): client error event cannot be emitted (#5559) Co-authored-by: monbrey Co-authored-by: Jan <66554238+vaporox@users.noreply.github.com> Co-authored-by: Vlad Frangu --- src/sharding/ShardClientUtil.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sharding/ShardClientUtil.js b/src/sharding/ShardClientUtil.js index 044d8ab35..e5b40b5b7 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); }); }