{"record":{"id":"174384c2aa1fd958","repo":"nestjs/nest","slug":"the-module-opaquetoken-module-is-taking-for","errorCode":null,"errorMessage":"The module \"${opaqueToken.module}\" is taking ${formattedTimeSpent}ms to serialize, this may be caused by larger objects statically assigned to the module. Consider changing the \"moduleIdGeneratorAlgorithm\" option to \"reference\" to improve the performance.","messagePattern":"The module \"(.+?)\" is taking (.+?)ms to serialize, this may be caused by larger objects statically assigned to the module\\. Consider changing the \"moduleIdGeneratorAlgorithm\" option to \"reference\" to improve the performance\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.ts","lineNumber":58,"sourceCode":"\n  public createForDynamic(\n    moduleCls: Type<unknown>,\n    dynamicMetadata: Omit<DynamicModule, 'module'>,\n  ): string {\n    const moduleId = this.getModuleId(moduleCls);\n    const moduleName = this.getModuleName(moduleCls);\n    const opaqueToken = {\n      id: moduleId,\n      module: moduleName,\n      dynamic: dynamicMetadata,\n    };\n    const start = performance.now();\n    const opaqueTokenString = this.getStringifiedOpaqueToken(opaqueToken);\n    const timeSpentInMs = performance.now() - start;\n\n    if (timeSpentInMs > 10) {\n      const formattedTimeSpent = timeSpentInMs.toFixed(2);\n      this.logger.warn(\n        `The module \"${opaqueToken.module}\" is taking ${formattedTimeSpent}ms to serialize, this may be caused by larger objects statically assigned to the module. Consider changing the \"moduleIdGeneratorAlgorithm\" option to \"reference\" to improve the performance.`,\n      );\n    }\n\n    return this.hashString(opaqueTokenString);\n  }\n\n  public getStringifiedOpaqueToken(opaqueToken: object | undefined): string {\n    // Uses safeStringify instead of JSON.stringify to support circular dynamic modules\n    // The replacer function is also required in order to obtain real class names\n    // instead of the unified \"Function\" key\n    return opaqueToken ? stringify(opaqueToken, this.replacer) : '';\n  }\n\n  public getModuleId(metatype: Type<unknown>): string {\n    let moduleId = this.moduleIdsCache.get(metatype);\n    if (moduleId) {\n      return moduleId;","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/nestjs/nest/blob/dd75d7bd8c5e88048587e6768d36eb695f3e7a25/packages/core/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.ts#L40-L76","documentation":"Error \"The module \"${opaqueToken.module}\" is taking ${formattedTimeSpent}ms to serialize, this may be caused by larger objects statically assigned to the module. Consider changing the \"moduleIdGeneratorAlgorithm\" option to \"reference\" to improve the performance.\" thrown in nestjs/nest.","triggerScenarios":"Thrown at packages/core/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.ts:58 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":"dd75d7bd8c5e88048587e6768d36eb695f3e7a25","analyzedAt":"2026-08-21T19:39:39.867Z","contentChangedAt":"2026-08-21T19:39:39.867Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}