From cd743bc8a7b015efff462cc0f34096e5f1cda501 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 14 Jan 2025 18:45:46 +0300 Subject: [PATCH] fix: updated eslint errors /src/middlewares/timeout.js /src/transit.js --- src/middlewares/timeout.js | 2 +- src/transit.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/middlewares/timeout.js b/src/middlewares/timeout.js index 59de2899..95fdba0a 100644 --- a/src/middlewares/timeout.js +++ b/src/middlewares/timeout.js @@ -42,7 +42,7 @@ module.exports = function (broker) { }); if (ctx.params instanceof Stream) { - ctx.params.emit('moleculer-timeout-middleware', ctx.options.timeout) + ctx.params.emit("moleculer-timeout-middleware", ctx.options.timeout); } err = new RequestTimeoutError({ action: actionName, nodeID }); diff --git a/src/transit.js b/src/transit.js index f72f714b..e3e2adac 100644 --- a/src/transit.js +++ b/src/transit.js @@ -551,12 +551,12 @@ 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); - }) + }); } if (payload.seq > pass.$prevSeq + 1) { @@ -872,11 +872,11 @@ class Transit { this.pendingRequests.set(ctx.id, request); if (request.stream) { - const pass = request.ctx.params + 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`); + }); } // Publish request @@ -1118,7 +1118,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)); } }