Skip to content

Commit d16c035

Browse files
refactor: rename ERROR to CONNECT_ERROR
The meaning is not modified: this packet type is still used by the server when the connection to a namespace is refused.
1 parent 5c73733 commit d16c035

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Diff for: lib/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class Client {
9191
} else {
9292
debug("creation of namespace %s was denied", name);
9393
this._packet({
94-
type: PacketType.ERROR,
94+
type: PacketType.CONNECT_ERROR,
9595
nsp: name,
9696
data: "Invalid namespace"
9797
});

Diff for: lib/socket.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import base64id from "base64id";
1212
const debug = debugModule("socket.io:socket");
1313

1414
export const RESERVED_EVENTS = new Set([
15-
"error",
1615
"connect",
16+
"connect_error",
1717
"disconnect",
1818
"disconnecting",
1919
// EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
@@ -316,7 +316,7 @@ export class Socket extends EventEmitter {
316316
this.ondisconnect();
317317
break;
318318

319-
case PacketType.ERROR:
319+
case PacketType.CONNECT_ERROR:
320320
this._onerror(new Error(packet.data));
321321
}
322322
}
@@ -438,7 +438,7 @@ export class Socket extends EventEmitter {
438438
* @private
439439
*/
440440
_error(err) {
441-
this.packet({ type: PacketType.ERROR, data: err });
441+
this.packet({ type: PacketType.CONNECT_ERROR, data: err });
442442
}
443443

444444
/**

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"debug": "~4.1.0",
4040
"engine.io": "~4.0.0",
4141
"socket.io-adapter": "2.0.3-rc2",
42-
"socket.io-parser": "4.0.1-rc2"
42+
"socket.io-parser": "4.0.1-rc3"
4343
},
4444
"devDependencies": {
4545
"@types/cookie": "^0.4.0",

Diff for: test/socket.io.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1711,8 +1711,8 @@ describe("socket.io", () => {
17111711
srv.listen(() => {
17121712
const socket = client(srv);
17131713
sio.on("connection", s => {
1714-
expect(() => s.emit("error")).to.throwException(
1715-
/"error" is a reserved event name/
1714+
expect(() => s.emit("connect_error")).to.throwException(
1715+
/"connect_error" is a reserved event name/
17161716
);
17171717
socket.close();
17181718
done();

0 commit comments

Comments
 (0)