{"record":{"id":"79554fee2e60dc99","repo":"discourse/discourse","slug":"on-cleanup-can-only-be-called-once","errorCode":null,"errorMessage":"on.cleanup can only be called once","messagePattern":"on\\.cleanup can only be called once","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/discourse/app/helpers/helper-fn.js","lineNumber":35,"sourceCode":"\n    constructor() {\n      super(...arguments);\n      registerDestructor(this, this.cleanup);\n    }\n\n    compute(positional, named) {\n      if (positional.length) {\n        throw new Error(\n          \"Positional arguments are not permitted for helperFn-defined helpers. Use named arguments instead.\"\n        );\n      }\n\n      this.cleanup();\n\n      const on = {\n        cleanup: (fn) => {\n          if (this.cleanupFn) {\n            throw new Error(\"on.cleanup can only be called once\");\n          }\n          this.cleanupFn = fn;\n        },\n      };\n\n      return callback(named, on);\n    }\n\n    @bind\n    cleanup() {\n      this.cleanupFn?.();\n      this.cleanupFn = null;\n    }\n  };\n}\n","sourceCodeStart":17,"sourceCodeEnd":51,"githubUrl":"https://github.com/discourse/discourse/blob/1b2d7253e854205d2c95c80b2c6a1cdd42e45059/frontend/discourse/app/helpers/helper-fn.js#L17-L51","documentation":"Error \"on.cleanup can only be called once\" thrown in discourse/discourse.","triggerScenarios":"Thrown at frontend/discourse/app/helpers/helper-fn.js:35 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":"1b2d7253e854205d2c95c80b2c6a1cdd42e45059","analyzedAt":"2026-08-26T03:11:08.302Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}