discourse/discourse · error · Error

on.cleanup can only be called once

Error message

on.cleanup can only be called once

What it means

Error "on.cleanup can only be called once" thrown in discourse/discourse.

Source

Thrown at frontend/discourse/app/helpers/helper-fn.js:35

    constructor() {
      super(...arguments);
      registerDestructor(this, this.cleanup);
    }

    compute(positional, named) {
      if (positional.length) {
        throw new Error(
          "Positional arguments are not permitted for helperFn-defined helpers. Use named arguments instead."
        );
      }

      this.cleanup();

      const on = {
        cleanup: (fn) => {
          if (this.cleanupFn) {
            throw new Error("on.cleanup can only be called once");
          }
          this.cleanupFn = fn;
        },
      };

      return callback(named, on);
    }

    @bind
    cleanup() {
      this.cleanupFn?.();
      this.cleanupFn = null;
    }
  };
}

View on GitHub (pinned to 1b2d7253e8)

When it happens

Trigger: Thrown at frontend/discourse/app/helpers/helper-fn.js:35 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of discourse/discourse@1b2d7253e8 (2026-08-26). Data as JSON: /api/errors/79554fee2e60dc99. Report an issue: GitHub.