Skip to content

Commit f4bcf7d

Browse files
committed
move cleanup to function
1 parent 7c45aa1 commit f4bcf7d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/transports-uws/polling.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ export class Polling extends Transport {
159159

160160
const onEnd = (buffer) => {
161161
this.onData(buffer.toString());
162-
this.dataReq = this.dataRes = null;
162+
this.onDataRequestCleanup();
163163
res.end("ok");
164164
};
165165

166166
res.onAborted(() => {
167-
this.dataReq = this.dataRes = null;
167+
this.onDataRequestCleanup();
168168
this.onError("data request connection closed prematurely");
169169
});
170170

@@ -190,7 +190,7 @@ export class Polling extends Transport {
190190
if (totalLength != contentLengthHeader) {
191191
this.onError("content-length mismatch");
192192
res.writeStatus("400 content-length mismatch").end();
193-
this.dataReq = this.dataRes = null;
193+
this.onDataRequestCleanup();
194194
return;
195195
}
196196
onEnd(buffer);
@@ -201,6 +201,15 @@ export class Polling extends Transport {
201201
});
202202
}
203203

204+
/**
205+
* Cleanup onDataRequest.
206+
*
207+
* @api private
208+
*/
209+
onDataRequestCleanup() {
210+
this.dataReq = this.dataRes = null;
211+
}
212+
204213
/**
205214
* Processes the incoming data payload.
206215
*

0 commit comments

Comments
 (0)