Commit 02b0f73
committed
fix: only set 'connected' to true after middleware execution
The Socket instance is only considered connected when the "connection"
event is emitted, and not during the middleware(s) execution.
```js
io.use((socket, next) => {
console.log(socket.connected); // prints "false"
next();
});
io.on("connection", (socket) => {
console.log(socket.connected); // prints "true"
});
```
Related: #41291 parent c0d8c5a commit 02b0f73
2 files changed
+28
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
130 | | - | |
| 129 | + | |
131 | 130 | | |
132 | 131 | | |
133 | 132 | | |
| |||
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
166 | | - | |
167 | | - | |
168 | 165 | | |
169 | 166 | | |
170 | 167 | | |
| |||
342 | 339 | | |
343 | 340 | | |
344 | 341 | | |
| 342 | + | |
345 | 343 | | |
346 | 344 | | |
347 | 345 | | |
| |||
489 | 487 | | |
490 | 488 | | |
491 | 489 | | |
492 | | - | |
493 | 490 | | |
494 | 491 | | |
495 | 492 | | |
| |||
631 | 628 | | |
632 | 629 | | |
633 | 630 | | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
634 | 638 | | |
635 | 639 | | |
636 | 640 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2726 | 2726 | | |
2727 | 2727 | | |
2728 | 2728 | | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
2729 | 2748 | | |
2730 | 2749 | | |
2731 | 2750 | | |
| |||
0 commit comments