Skip to content

Commit

Permalink
move cleanup to function
Browse files Browse the repository at this point in the history
  • Loading branch information
e3dio committed Feb 22, 2022
1 parent 7c45aa1 commit f4bcf7d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/transports-uws/polling.ts
Expand Up @@ -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");
});

Expand All @@ -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);
Expand All @@ -201,6 +201,15 @@ export class Polling extends Transport {
});
}

/**
* Cleanup onDataRequest.
*
* @api private
*/
onDataRequestCleanup() {
this.dataReq = this.dataRes = null;
}

/**
* Processes the incoming data payload.
*
Expand Down

0 comments on commit f4bcf7d

Please sign in to comment.