ReactiveX/rxjs · critical · TypeError

Cannot initialize @rxjs/observable-polyfill: AbortController

Error message

Cannot initialize @rxjs/observable-polyfill: AbortController.prototype.abort is unavailable

What it means

The polyfill requires AbortController.prototype.abort (a real function on the prototype) to wire cancellation into the platform Subscriber lifecycle before it can install its Observable. If AbortController is missing, or abort is only an own/instance property or not a function, initialization refuses to proceed.

Source

Thrown at packages/observable-polyfill/src/index.ts:1385

    if (rollbackErrors.length > 0) {
      throw new AggregateError(
        [error, ...rollbackErrors],
        'Cannot initialize @rxjs/observable-polyfill and could not fully restore the realm'
      );
    }
    throw error;
  }
}

function initializeObservablePolyfill(): void {
  const installations: PropertyInstallation[] = [];
  const activeObservable = (globalThis as typeof globalThis & { Observable?: ObservableCtor }).Observable;

  if (activeObservable === undefined) {
    const AbortControllerCtor = globalThis.AbortController;
    const abortDescriptor = AbortControllerCtor && Object.getOwnPropertyDescriptor(AbortControllerCtor.prototype, 'abort');
    if (!AbortControllerCtor || !abortDescriptor || typeof abortDescriptor.value !== 'function') {
      throw new TypeError('Cannot initialize @rxjs/observable-polyfill: AbortController.prototype.abort is unavailable');
    }

    nativeAbort = abortDescriptor.value;
    installations.push(
      preparePropertyInstallation(
        AbortControllerCtor.prototype,
        'abort',
        { ...abortDescriptor, value: abortWithObservableAlgorithms },
        'AbortController.prototype.abort'
      ),
      preparePropertyInstallation(
        globalThis,
        'Subscriber',
        {
          configurable: true,
          enumerable: false,
          value: Subscriber,
          writable: true,

View on GitHub (pinned to 54796b38a5)

Solutions

  1. Provide a conforming AbortController (upgrade Node to >=15, or install a spec-compliant polyfill like abort-controller before importing @rxjs/observable-polyfill)
  2. Verify Object.getOwnPropertyDescriptor(AbortController.prototype, 'abort') returns { value: function } in your environment
  3. If you ship a custom AbortController, define abort on the prototype: AbortController.prototype.abort = function () {...}

Example fix

// before
import '@rxjs/observable-polyfill'; // TypeError: AbortController.prototype.abort is unavailable
// after
import 'abort-controller/polyfill'; // or upgrade Node >= 15
import '@rxjs/observable-polyfill';
Defensive patterns

Strategy: validation

Validate before calling

function canInstallPolyfill() {
  return typeof globalThis.AbortController === 'function' &&
    typeof Object.getOwnPropertyDescriptor(AbortController.prototype, 'abort')?.value === 'function';
}

Type guard

const hasProtoAbort = (c: unknown): c is typeof AbortController =>
  typeof c === 'function' &&
  typeof Object.getOwnPropertyDescriptor((c as any).prototype, 'abort')?.value === 'function';

Prevention

When it happens

Trigger: Calling the polyfill install when globalThis.Observable is undefined AND globalThis.AbortController is missing (old Node <15, legacy browsers), or when an environment ships an AbortController shim whose abort is not a prototype-level function value.

Common situations: Node <15, IE11, jsdom configurations without AbortController, or overwriting globalThis.AbortController with a class that defines abort as an instance field instead of a prototype method.

Related errors


AI-assisted analysis of ReactiveX/rxjs@54796b38a5 (2026-08-28). Data as JSON: /api/errors/a7aff0938936a24e. Report an issue: GitHub.