diff --git a/lib/client.ts b/lib/client.ts index 75c1350b88..cfb346130e 100644 --- a/lib/client.ts +++ b/lib/client.ts @@ -91,7 +91,7 @@ export class Client { } else { debug("creation of namespace %s was denied", name); this._packet({ - type: PacketType.ERROR, + type: PacketType.CONNECT_ERROR, nsp: name, data: "Invalid namespace" }); diff --git a/lib/socket.ts b/lib/socket.ts index b0a2ccbdd7..b06837d77b 100644 --- a/lib/socket.ts +++ b/lib/socket.ts @@ -12,8 +12,8 @@ import base64id from "base64id"; const debug = debugModule("socket.io:socket"); export const RESERVED_EVENTS = new Set([ - "error", "connect", + "connect_error", "disconnect", "disconnecting", // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener @@ -316,7 +316,7 @@ export class Socket extends EventEmitter { this.ondisconnect(); break; - case PacketType.ERROR: + case PacketType.CONNECT_ERROR: this._onerror(new Error(packet.data)); } } @@ -438,7 +438,7 @@ export class Socket extends EventEmitter { * @private */ _error(err) { - this.packet({ type: PacketType.ERROR, data: err }); + this.packet({ type: PacketType.CONNECT_ERROR, data: err }); } /** diff --git a/package.json b/package.json index 7287101255..cab37a0dfe 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "debug": "~4.1.0", "engine.io": "~4.0.0", "socket.io-adapter": "2.0.3-rc2", - "socket.io-parser": "4.0.1-rc2" + "socket.io-parser": "4.0.1-rc3" }, "devDependencies": { "@types/cookie": "^0.4.0", diff --git a/test/socket.io.ts b/test/socket.io.ts index cfcf62c481..03cec50742 100644 --- a/test/socket.io.ts +++ b/test/socket.io.ts @@ -1711,8 +1711,8 @@ describe("socket.io", () => { srv.listen(() => { const socket = client(srv); sio.on("connection", s => { - expect(() => s.emit("error")).to.throwException( - /"error" is a reserved event name/ + expect(() => s.emit("connect_error")).to.throwException( + /"connect_error" is a reserved event name/ ); socket.close(); done();