Skip to content

Commit

Permalink
fix: updated eslint errors
Browse files Browse the repository at this point in the history
/src/transit.js
  • Loading branch information
JS-AK committed Jan 14, 2025
1 parent cd743bc commit 58b8548
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/transit.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,13 @@ class Transit {

this.pendingReqStreams.set(payload.id, { sender: payload.sender, stream: pass });

pass.on("moleculer-timeout-middleware", (timeout) => {
pass.on("moleculer-timeout-middleware", timeout => {
setTimeout(() => {
this.pendingReqStreams.delete(payload.id);
this._destroyStreamIfPossible(pass, `Pending request stream ${payload.id} have been closed by timeout ${timeout} ms`);
this._destroyStreamIfPossible(
pass,
`Pending request stream ${payload.id} have been closed by timeout ${timeout} ms`
);
}, 1000);
});
}
Expand Down Expand Up @@ -874,8 +877,11 @@ class Transit {
if (request.stream) {
const pass = request.ctx.params;

pass.on("moleculer-timeout-middleware", (timeout) => {
this._destroyStreamIfPossible(pass, `Request stream ${ctx.id} have been closed by timeout ${timeout} ms`);
pass.on("moleculer-timeout-middleware", timeout => {
this._destroyStreamIfPossible(
pass,
`Request stream ${ctx.id} have been closed by timeout ${timeout} ms`
);
});
}

Expand Down Expand Up @@ -1118,7 +1124,7 @@ class Transit {
*/
_destroyStreamIfPossible(stream, errorMessage) {
if (!stream.destroyed && stream.destroy) {
stream.on("error", (err) => this.logger.error(err.message));
stream.on("error", err => this.logger.error(err.message));
stream.destroy(new Error(errorMessage));
}
}
Expand Down

0 comments on commit 58b8548

Please sign in to comment.