{"id":"7bfd7fa3a7a3a073","repo":"socketio/socket.io","slug":"no-adapter-for-this-namespace-are-you-trying-to-g","errorCode":null,"errorMessage":"No adapter for this namespace, are you trying to get the list of clients of a dynamic namespace?","messagePattern":"No adapter for this namespace, are you trying to get the list of clients of a dynamic namespace\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/socket.io/lib/broadcast-operator.ts","lineNumber":349,"sourceCode":"          err.responses = responses;\n          return reject(err);\n        } else {\n          return resolve(responses);\n        }\n      });\n      this.emit(ev, ...(args as any[] as EventParams<EmitEvents, Ev>));\n    });\n  }\n\n  /**\n   * Gets a list of clients.\n   *\n   * @deprecated this method will be removed in the next major release, please use {@link Server#serverSideEmit} or\n   * {@link fetchSockets} instead.\n   */\n  public allSockets(): Promise<Set<SocketId>> {\n    if (!this.adapter) {\n      throw new Error(\n        \"No adapter for this namespace, are you trying to get the list of clients of a dynamic namespace?\",\n      );\n    }\n    return this.adapter.sockets(this.rooms);\n  }\n\n  /**\n   * Returns the matching socket instances. This method works across a cluster of several Socket.IO servers.\n   *\n   * Note: this method also works within a cluster of multiple Socket.IO servers, with a compatible {@link Adapter}.\n   *\n   * @example\n   * // return all Socket instances\n   * const sockets = await io.fetchSockets();\n   *\n   * // return all Socket instances in the \"room1\" room\n   * const sockets = await io.in(\"room1\").fetchSockets();\n   *","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/socketio/socket.io/blob/ae7fb46e08c5ed964b4a1ea8b1703e816511598e/packages/socket.io/lib/broadcast-operator.ts#L331-L367","documentation":"Thrown by the deprecated BroadcastOperator.allSockets() when this.adapter is undefined (the BroadcastOperator was constructed without an adapter). allSockets() delegates to the namespace adapter; without one it cannot enumerate sockets. The message specifically flags dynamic namespaces, which do not have a concrete adapter instance to query.","triggerScenarios":"Calling allSockets() on a BroadcastOperator that has no adapter — typically obtained from a dynamic/regex namespace (io.of(/^/dynamic-/)) whose matching Namespace is abstract, or by constructing a BroadcastOperator directly without injecting an adapter.","commonSituations":"Using io.of(/regex/).allSockets() on a dynamic namespace; or calling the deprecated allSockets() (the message itself notes deprecation) instead of fetchSockets/allSockets on a concrete namespace.","solutions":["Use a concrete namespace (io.of('/name')) instead of a dynamic regex namespace when you need to list sockets.","Migrate from the deprecated allSockets() to fetchSockets() on a concrete namespace.","For dynamic namespaces, iterate matched namespaces via io.of(/^/.../).sockets or resolve a specific namespace instance first."],"exampleFix":"// before\nconst ids = await io.of(/^/tenant-/).allSockets(); // throws\n\n// after\nconst ids = await io.of('/tenant-1').allSockets(); // concrete namespace\n// or, the non-deprecated alternative:\nconst sockets = await io.of('/tenant-1').fetchSockets();","handlingStrategy":"validation","validationCode":"function hasAdapter(operator){ return !!operator.adapter; }","typeGuard":"function isConcreteNamespace(ns){ return !!ns && !!ns.adapter; }","tryCatchPattern":null,"preventionTips":["Avoid calling the deprecated allSockets() on dynamic (regex) namespaces.","Prefer fetchSockets() on a concrete namespace.","Resolve a specific namespace instance before listing clients."],"tags":["server","namespace","adapter","deprecated","dynamic-namespace"],"analyzedSha":"ae7fb46e08c5ed964b4a1ea8b1703e816511598e","analyzedAt":"2026-08-03T19:08:14.127Z","schemaVersion":2}