From f4bcf7dfcd8e700cde20dfb05229864ff72b7c6a Mon Sep 17 00:00:00 2001 From: e3dio <85405955+e3dio@users.noreply.github.com> Date: Tue, 22 Feb 2022 13:59:24 -0700 Subject: [PATCH] move cleanup to function --- lib/transports-uws/polling.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/transports-uws/polling.ts b/lib/transports-uws/polling.ts index 169689e7..42dd22fc 100644 --- a/lib/transports-uws/polling.ts +++ b/lib/transports-uws/polling.ts @@ -159,12 +159,12 @@ export class Polling extends Transport { const onEnd = (buffer) => { this.onData(buffer.toString()); - this.dataReq = this.dataRes = null; + this.onDataRequestCleanup(); res.end("ok"); }; res.onAborted(() => { - this.dataReq = this.dataRes = null; + this.onDataRequestCleanup(); this.onError("data request connection closed prematurely"); }); @@ -190,7 +190,7 @@ export class Polling extends Transport { if (totalLength != contentLengthHeader) { this.onError("content-length mismatch"); res.writeStatus("400 content-length mismatch").end(); - this.dataReq = this.dataRes = null; + this.onDataRequestCleanup(); return; } onEnd(buffer); @@ -201,6 +201,15 @@ export class Polling extends Transport { }); } + /** + * Cleanup onDataRequest. + * + * @api private + */ + onDataRequestCleanup() { + this.dataReq = this.dataRes = null; + } + /** * Processes the incoming data payload. *