-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with namespaces and regex #4615
Comments
I could indeed reproduce the issue, thanks. This is a known limitation with dynamic namespaces, any existing static namespaces have the priority over the dynamic ones. We could maybe fix this by running the regex against any existing namespaces: io.of('test1');
io.of(/^.*$/); // add test1 as a child of the parent namespace (since it matches the regex)
io.of('test2'); // add test2 as a child of the parent namespace (since it matches the regex) That might be a surprising behavior for the end users though. What do you think? Related: #4164 |
@ksowa this should be fixed by 0d0a7a2, included in version A namespace whose name matches the regex of a parent namespace will now be added as a child of this namespace: const parentNamespace = io.of(/^\/dynamic-\d+$/);
parentNamespace.on("connection", (socket) => {
console.log(`connection on namespace ${socket.nsp.name}`);
}); And then somewhere else: io.of("/dynamic-101"); Could you please check? |
@darrachequesne it is indeed fixed in |
Awesome, thanks for the feedback 👍 |
Namespaces that match the regex of a parent namespace will now be added as a child of this namespace: ```js const parentNamespace = io.of(/^\/dynamic-\d+$/); const childNamespace = io.of("/dynamic-101"); ``` Related: - socketio#4615 - socketio#4164 - socketio#4015 - socketio#3960
Namespaces that match the regex of a parent namespace will now be added as a child of this namespace: ```js const parentNamespace = io.of(/^\/dynamic-\d+$/); const childNamespace = io.of("/dynamic-101"); ``` Related: - socketio#4615 - socketio#4164 - socketio#4015 - socketio#3960
Describe the bug
There seems to be a problem with
connection
callback on the server if the following occur:io.of(/^.*$/)...
)connection
callback is not triggerredTo Reproduce
Socket.IO server version:
4.5.4
Server
Socket.IO client version:
4.5.4
Client
Expected behavior
The
connection
callback should be triggered regardless if the first message has been emitted to the namespace before or after any clients connect to that namespace.Additional context
If we change the server code to the below, it works without any problem.
(first message emitted after first client connects)
OR (namespace is not dynamic):
OR (client connecting to another namespace):
The text was updated successfully, but these errors were encountered: