Skip to content

Commit f27a6c3

Browse files
refactor: remove useless reference
A reference to the initial IncomingMessage object (the first HTTP request of the session) is kept in memory by default (`socket.request`), so its attached ServerResponse object (`req.res`) would not be garbage-collected. This will now be the case. Note: the IncomingMessage object is needed in two cases: - when working with the `express-session` middleware (`request.session`) - when fetching the certificate of the client with `request.socket.getPeerCertificate()` That's why removing it would be a breaking change.
1 parent 2da559a commit f27a6c3

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/transports-uws/polling.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export class Polling extends Transport {
5555
*/
5656
onRequest(req) {
5757
const res = req.res;
58+
// remove the reference to the ServerResponse object (as the first request of the session is kept in memory by default)
59+
req.res = null;
5860

5961
if (req.getMethod() === "get") {
6062
this.onPollRequest(req, res);

lib/transports/polling.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export class Polling extends Transport {
5454
*/
5555
onRequest(req: IncomingMessage & { res: ServerResponse }) {
5656
const res = req.res;
57+
// remove the reference to the ServerResponse object (as the first request of the session is kept in memory by default)
58+
req.res = null;
5759

5860
if ("GET" === req.method) {
5961
this.onPollRequest(req, res);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy