From e24b27b8efaf621af372f44b7c0ece3d801c603e Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Mon, 28 Feb 2022 07:01:44 +0100 Subject: [PATCH 1/4] refactor: return an HTTP 413 response for too large payloads Before this, the connection was closed abrutly with an HTTP 502 response. See also: https://github.com/socketio/engine.io/commit/f8100f92370f4228fbcc7a92bcc4bd85d9c0f001 Related: https://github.com/socketio/socket.io/issues/4293 --- lib/transports/polling.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/transports/polling.ts b/lib/transports/polling.ts index c96010f1..fdb4d264 100644 --- a/lib/transports/polling.ts +++ b/lib/transports/polling.ts @@ -52,7 +52,7 @@ export class Polling extends Transport { * @param {http.IncomingMessage} * @api private */ - onRequest(req) { + onRequest(req: IncomingMessage & { res: ServerResponse }) { const res = req.res; if ("GET" === req.method) { @@ -112,7 +112,7 @@ export class Polling extends Transport { * * @api private */ - onDataRequest(req, res) { + onDataRequest(req: IncomingMessage, res: ServerResponse) { if (this.dataReq) { // assert: this.dataRes, '.dataReq and .dataRes should be (un)set together' this.onError("data request overlap from client"); @@ -155,8 +155,8 @@ export class Polling extends Transport { } if (contentLength > this.maxHttpBufferSize) { - chunks = isBinary ? Buffer.concat([]) : ""; - req.connection.destroy(); + res.writeHead(413).end(); + cleanup(); } }; From 657f04e0b81cc31e2a97d163c2fab972c6a38b3f Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Thu, 10 Mar 2022 14:13:48 +0100 Subject: [PATCH 2/4] chore: add Node.js 16 in the test matrix See also: https://github.com/nodejs/Release --- .github/workflows/ci.yml | 2 +- package-lock.json | 18 +++++++++--------- package.json | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c51ab3f5..e9ba9626 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x] + node-version: [14, 16] steps: - uses: actions/checkout@v2 diff --git a/package-lock.json b/package-lock.json index 9e8dca05..f5e546ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,12 +17,12 @@ "cookie": "~0.4.1", "cors": "~2.8.5", "debug": "~4.3.1", - "engine.io-parser": "~5.0.0", + "engine.io-parser": "~5.0.3", "ws": "~8.2.3" }, "devDependencies": { "babel-eslint": "^8.0.2", - "eiows": "^3.3.0", + "eiows": "^3.8.0", "engine.io-client": "6.1.0", "engine.io-client-v3": "npm:engine.io-client@3.5.2", "expect.js": "^0.3.1", @@ -542,13 +542,13 @@ } }, "node_modules/eiows": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/eiows/-/eiows-3.3.2.tgz", - "integrity": "sha512-7cwZl/itR8NP6YXObVo583sxQcoKdcpeuRZqelnuqlQZvJH7oBSVvMRq8vZQkL4IXCXJPL8iC2M6haSawmtOsg==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/eiows/-/eiows-3.8.0.tgz", + "integrity": "sha512-ElPW+EakV8NSsA5QWJCWEx88LO/xyqMFilvsZ4P9+uyVS4ikbq2zndnYC++XLKysC+c922bGkAKeNrqWNmwNyg==", "dev": true, "hasInstallScript": true, "engines": { - "node": ">=8.12.0 <15.0" + "node": ">=8.12.0 <18.0" } }, "node_modules/emoji-regex": { @@ -2367,9 +2367,9 @@ "dev": true }, "eiows": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/eiows/-/eiows-3.3.2.tgz", - "integrity": "sha512-7cwZl/itR8NP6YXObVo583sxQcoKdcpeuRZqelnuqlQZvJH7oBSVvMRq8vZQkL4IXCXJPL8iC2M6haSawmtOsg==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/eiows/-/eiows-3.8.0.tgz", + "integrity": "sha512-ElPW+EakV8NSsA5QWJCWEx88LO/xyqMFilvsZ4P9+uyVS4ikbq2zndnYC++XLKysC+c922bGkAKeNrqWNmwNyg==", "dev": true }, "emoji-regex": { diff --git a/package.json b/package.json index 4ec39013..262eeccd 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ }, "devDependencies": { "babel-eslint": "^8.0.2", - "eiows": "^3.3.0", + "eiows": "^3.8.0", "engine.io-client": "6.1.0", "engine.io-client-v3": "npm:engine.io-client@3.5.2", "expect.js": "^0.3.1", From 088dcb4dff60df39785df13d0a33d3ceaa1dff38 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Thu, 10 Mar 2022 14:01:40 +0100 Subject: [PATCH 3/4] feat: add the "maxPayload" field in the handshake details So that clients in HTTP long-polling can decide how many packets they have to send to stay under the maxHttpBufferSize value. This is a backward compatible change which should not mandate a new major revision of the protocol (we stay in v4), as we only add a field in the JSON-encoded handshake data: ``` 0{"sid":"lv_VI97HAXpY6yYWAAAC","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":5000,"maxPayload":1000000} ``` Related: https://github.com/socketio/socket.io-client/issues/1531 --- lib/socket.ts | 3 ++- test/server.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/socket.ts b/lib/socket.ts index c3a81619..73b9b0f1 100644 --- a/lib/socket.ts +++ b/lib/socket.ts @@ -90,7 +90,8 @@ export class Socket extends EventEmitter { sid: this.id, upgrades: this.getAvailableUpgrades(), pingInterval: this.server.opts.pingInterval, - pingTimeout: this.server.opts.pingTimeout + pingTimeout: this.server.opts.pingTimeout, + maxPayload: this.server.opts.maxHttpBufferSize }) ); diff --git a/test/server.js b/test/server.js index fff27d58..906bdb6b 100644 --- a/test/server.js +++ b/test/server.js @@ -449,6 +449,7 @@ describe("server", () => { expect(obj.sid).to.be.a("string"); expect(obj.pingTimeout).to.be.a("number"); expect(obj.upgrades).to.be.an("array"); + expect(obj.maxPayload).to.eql(1000000); done(); }); }); @@ -3356,7 +3357,7 @@ describe("server", () => { expect(res.headers["set-cookie"].length).to.be(2); expect(res.headers["set-cookie"][1]).to.be("mycookie=456"); - const sid = JSON.parse(res.text.substring(4)).sid; + const sid = JSON.parse(res.text.substring(5)).sid; request .post(`http://localhost:${port}/engine.io/`) @@ -3393,7 +3394,7 @@ describe("server", () => { expect(res.headers["set-cookie"].length).to.be(2); expect(res.headers["set-cookie"][1]).to.be("mycookie=456"); - const sid = JSON.parse(res.text.substring(4)).sid; + const sid = JSON.parse(res.text.substring(5)).sid; request .post(`http://localhost:${port}/engine.io/`) From d7e3ab7956139304aa38ab5d1d2bb1d28baaf7fe Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Sun, 17 Apr 2022 23:53:53 +0200 Subject: [PATCH 4/4] chore(release): 6.2.0 Diff: https://github.com/socketio/engine.io/compare/6.1.3...6.2.0 --- CHANGELOG.md | 19 +++++++++++++++++++ package-lock.json | 44 ++++++++++++++++++-------------------------- package.json | 4 ++-- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 207ca1cd..cc6870b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +# [6.2.0](https://github.com/socketio/engine.io/compare/6.1.3...6.2.0) (2022-04-17) + + +### Features + +* add the "maxPayload" field in the handshake details ([088dcb4](https://github.com/socketio/engine.io/commit/088dcb4dff60df39785df13d0a33d3ceaa1dff38)) + +So that clients in HTTP long-polling can decide how many packets they have to send to stay under the maxHttpBufferSize +value. + +This is a backward compatible change which should not mandate a new major revision of the protocol (we stay in v4), as +we only add a field in the JSON-encoded handshake data: + +``` +0{"sid":"lv_VI97HAXpY6yYWAAAC","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":5000,"maxPayload":1000000} +``` + + + ## [6.1.3](https://github.com/socketio/engine.io/compare/6.1.2...6.1.3) (2022-02-23) diff --git a/package-lock.json b/package-lock.json index f5e546ec..4355bb44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "engine.io", - "version": "6.1.3", + "version": "6.2.0", "lockfileVersion": 2, "requires": true, "packages": { @@ -23,7 +23,7 @@ "devDependencies": { "babel-eslint": "^8.0.2", "eiows": "^3.8.0", - "engine.io-client": "6.1.0", + "engine.io-client": "6.2.0", "engine.io-client-v3": "npm:engine.io-client@3.5.2", "expect.js": "^0.3.1", "mocha": "^9.1.3", @@ -159,9 +159,9 @@ } }, "node_modules/@socket.io/component-emitter": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.0.0.tgz", - "integrity": "sha512-2pTGuibAXJswAPJjaKisthqS/NOK5ypG4LYT6tEAV0S/mxW0zOIvYvGK0V8w8+SHxAm6vRMSjqSalFXeBAqs+Q==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==", "dev": true }, "node_modules/@types/cookie": { @@ -558,20 +558,16 @@ "dev": true }, "node_modules/engine.io-client": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.1.0.tgz", - "integrity": "sha512-kNwjOjrU981utPZSzFbNU6lYda7B5xQs875x2DyCaalktt3ZSKc7DpCY18dml6JFzFH8dxsKAW0LMaGFMD7GmQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.0.tgz", + "integrity": "sha512-gz4quwdj6i17TihLOUv1mZ7/AcsrS0/Oq1ggmqod9/ULDraBIptYoZsyISLD9+chnvN6QmSZD7zuBGuiNk1hRw==", "dev": true, "dependencies": { - "@socket.io/component-emitter": "~3.0.0", + "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1", "engine.io-parser": "~5.0.0", - "has-cors": "1.1.0", - "parseqs": "0.0.6", - "parseuri": "0.0.6", "ws": "~8.2.3", - "xmlhttprequest-ssl": "~2.0.0", - "yeast": "0.1.2" + "xmlhttprequest-ssl": "~2.0.0" } }, "node_modules/engine.io-client-v3": { @@ -2064,9 +2060,9 @@ "integrity": "sha512-dOlCBKnDw4iShaIsH/bxujKTM18+2TOAsYz+KSc11Am38H4q5Xw8Bbz97ZYdrVNM+um3p7w86Bvvmcn9q+5+eQ==" }, "@socket.io/component-emitter": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.0.0.tgz", - "integrity": "sha512-2pTGuibAXJswAPJjaKisthqS/NOK5ypG4LYT6tEAV0S/mxW0zOIvYvGK0V8w8+SHxAm6vRMSjqSalFXeBAqs+Q==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==", "dev": true }, "@types/cookie": { @@ -2379,20 +2375,16 @@ "dev": true }, "engine.io-client": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.1.0.tgz", - "integrity": "sha512-kNwjOjrU981utPZSzFbNU6lYda7B5xQs875x2DyCaalktt3ZSKc7DpCY18dml6JFzFH8dxsKAW0LMaGFMD7GmQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.0.tgz", + "integrity": "sha512-gz4quwdj6i17TihLOUv1mZ7/AcsrS0/Oq1ggmqod9/ULDraBIptYoZsyISLD9+chnvN6QmSZD7zuBGuiNk1hRw==", "dev": true, "requires": { - "@socket.io/component-emitter": "~3.0.0", + "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1", "engine.io-parser": "~5.0.0", - "has-cors": "1.1.0", - "parseqs": "0.0.6", - "parseuri": "0.0.6", "ws": "~8.2.3", - "xmlhttprequest-ssl": "~2.0.0", - "yeast": "0.1.2" + "xmlhttprequest-ssl": "~2.0.0" } }, "engine.io-client-v3": { diff --git a/package.json b/package.json index 262eeccd..ff3daf62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "engine.io", - "version": "6.1.3", + "version": "6.2.0", "description": "The realtime engine behind Socket.IO. Provides the foundation of a bidirectional connection between client and server", "type": "commonjs", "main": "./build/engine.io.js", @@ -45,7 +45,7 @@ "devDependencies": { "babel-eslint": "^8.0.2", "eiows": "^3.8.0", - "engine.io-client": "6.1.0", + "engine.io-client": "6.2.0", "engine.io-client-v3": "npm:engine.io-client@3.5.2", "expect.js": "^0.3.1", "mocha": "^9.1.3", 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