From f927ba29efcfec5a1b4c7930c5ed993fd3cf5ff7 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Wed, 19 Jun 2024 10:44:04 +0200 Subject: [PATCH 1/3] test: fix tests on Node.js > 18 Reference: https://nodejs.org/api/buffer.html#class-blob --- test/socket.io.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/socket.io.js b/test/socket.io.js index 7fe059d4a9..ca812398a1 100644 --- a/test/socket.io.js +++ b/test/socket.io.js @@ -1858,7 +1858,7 @@ describe('socket.io', function(){ it('should not crash when messing with Object prototype (and other globals)', function(done){ Object.prototype.foo = 'bar'; global.File = ''; - global.Blob = []; + // global.Blob = []; var srv = http(); var sio = io(srv); srv.listen(function(){ From d30630ba10562bf987f4d2b42440fc41a828119c Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Wed, 19 Jun 2024 10:46:29 +0200 Subject: [PATCH 2/3] fix: add a noop handler for the error event Backported from main: https://github.com/socketio/socket.io/commit/15af22fc22bc6030fcead322c106f07640336115 --- lib/socket.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/socket.js b/lib/socket.js index bfdd77e856..cb7ba4123e 100644 --- a/lib/socket.js +++ b/lib/socket.js @@ -49,6 +49,8 @@ var flags = [ var emit = Emitter.prototype.emit; +function noop() {} + /** * Interface to a `Client` for a given `Namespace`. * @@ -72,6 +74,9 @@ function Socket(nsp, client, query){ this.fns = []; this.flags = {}; this._rooms = []; + + // prevents crash when the socket receives an "error" event without listener + this.on('error', noop); } /** @@ -427,12 +432,7 @@ Socket.prototype.ondisconnect = function(){ */ Socket.prototype.onerror = function(err){ - if (this.listeners('error').length) { - this.emit('error', err); - } else { - console.error('Missing error handler on `socket`.'); - console.error(err.stack); - } + this.emit('error', err); }; /** From 88b2cdb6abd38d6466fa4360748f2f67d8837ad4 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Wed, 19 Jun 2024 10:48:24 +0200 Subject: [PATCH 3/3] chore(release): 2.5.1 Release notes: https://github.com/socketio/socket.io/releases/tag/2.5.1 Diff: https://github.com/socketio/socket.io/compare/2.5.0...2.5.1 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29267b4e50..ec09c35079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [2.5.1](https://github.com/socketio/socket.io/compare/2.5.0...2.5.1) (2024-06-19) + + +### Bug Fixes + +* add a noop handler for the error event ([d30630b](https://github.com/socketio/socket.io/commit/d30630ba10562bf987f4d2b42440fc41a828119c)) + + + # [2.5.0](https://github.com/socketio/socket.io/compare/2.4.1...2.5.0) (2022-06-26) diff --git a/package.json b/package.json index 975856394c..e1d66c8661 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "socket.io", - "version": "2.5.0", + "version": "2.5.1", "description": "node.js realtime framework server", "keywords": [ "realtime",