toeverything/AFFiNE · error · Error

Handler for operation [${op.name}] is not registered.

Error message

Handler for operation [${op.name}] is not registered.

What it means

ob$ looks up the registered handler for an incoming call/subscribe operation and throws when the op name was never registered, so remote operation requests for unknown operations fail immediately instead of hanging.

Source

Thrown at packages/common/infra/src/op/consumer.ts:252

  ) {
    this.eventBus.on(`before:${op}`, handler);
  }

  after<Op extends OpNames<Ops>>(
    op: Op,
    handler: (...args: [...OpInput<Ops, Op>, OpOutput<Ops, Op>]) => void
  ) {
    this.eventBus.on(`after:${op}`, handler);
  }

  /**
   * @internal
   */
  ob$(op: CallMessage | SubscribeMessage, signal: AbortSignal) {
    return defer(() => {
      const handler = this.registeredOpHandlers.get(op.name as any);
      if (!handler) {
        throw new Error(
          `Handler for operation [${op.name}] is not registered.`
        );
      }

      const ret$ = handler(op.payload, { signal });

      let ob$: Observable<any>;
      if (ret$ instanceof Promise) {
        ob$ = from(ret$);
      } else if (ret$ instanceof Observable) {
        ob$ = ret$;
      } else {
        ob$ = of(ret$);
      }

      return ob$.pipe(takeUntil(fromEvent(signal, 'abort')));
    });
  }

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Register a handler for the named operation before consuming it.
  2. Check the operation name for typos and ensure the producer and consumer agree on it.
  3. Confirm the module registering the handler is loaded before the operation is invoked.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/common/infra/src/op/consumer.ts:252 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/eb575b09873cb769. Report an issue: GitHub.