{"record":{"id":"846206d42c6fc670","repo":"nestjs/nest","slug":"usewebsocketadapter-was-called-after-websocket-g","errorCode":null,"errorMessage":"useWebSocketAdapter() was called after WebSocket gateways were already initialized. The provided adapter will be stored but will NOT be applied to existing gateways — they remain bound to the previously installed adapter. To install a custom adapter, call app.useWebSocketAdapter(...) BEFORE app.init() (or app.listen()).","messagePattern":"useWebSocketAdapter\\(\\) was called after WebSocket gateways were already initialized\\. The provided adapter will be stored but will NOT be applied to existing gateways — they remain bound to the previously installed adapter\\. To install a custom adapter, call app\\.useWebSocketAdapter\\(\\.\\.\\.\\) BEFORE app\\.init\\(\\) \\(or app\\.listen\\(\\)\\)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/nest-application.ts","lineNumber":486,"sourceCode":"  }\n\n  public setGlobalPrefix(prefix: string, options?: GlobalPrefixOptions): this {\n    this.config.setGlobalPrefix(prefix);\n    if (options) {\n      const exclude = options?.exclude\n        ? mapToExcludeRoute(options.exclude)\n        : [];\n      this.config.setGlobalPrefixOptions({\n        ...options,\n        exclude,\n      });\n    }\n    return this;\n  }\n\n  public useWebSocketAdapter(adapter: WebSocketAdapter): this {\n    if (this.isWsModuleRegistered) {\n      this.logger.warn(\n        'useWebSocketAdapter() was called after WebSocket gateways were already initialized. The provided adapter will be stored but will NOT be applied to existing gateways — they remain bound to the previously installed adapter. To install a custom adapter, call app.useWebSocketAdapter(...) BEFORE app.init() (or app.listen()).',\n      );\n    }\n    this.config.setIoAdapter(adapter);\n    return this;\n  }\n\n  public useGlobalFilters(...filters: ExceptionFilter[]): this {\n    filters = this.applyInstanceDecoratorIfRegistered<ExceptionFilter>(\n      ...filters,\n    );\n    this.config.useGlobalFilters(...filters);\n    filters.forEach(item =>\n      this.graphInspector.insertOrphanedEnhancer({\n        subtype: 'filter',\n        ref: item,\n      }),\n    );","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/nestjs/nest/blob/3f8a0ce1832fb30053f55856088371b097bbf7e1/packages/core/nest-application.ts#L468-L504","documentation":"Error \"useWebSocketAdapter() was called after WebSocket gateways were already initialized. The provided adapter will be stored but will NOT be applied to existing gateways — they remain bound to the previously installed adapter. To install a custom adapter, call app.useWebSocketAdapter(...) BEFORE app.init() (or app.listen()).\" thrown in nestjs/nest.","triggerScenarios":"Thrown at packages/core/nest-application.ts:485 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f8a0ce1832fb30053f55856088371b097bbf7e1","analyzedAt":"2026-08-21T19:39:39.867Z","contentChangedAt":"2026-08-21T19:39:39.867Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}