Skip to content

node:util: expose transferable AbortSignal helpers #3419

Closed

Description

@andrewtdiz

Summary

util.transferableAbortController() and util.transferableAbortSignal(signal) should be callable Node helpers for creating/marking AbortSignals that can be transferred through structured clone and worker-message paths. Perry currently rejects the helper at compile time as an unimplemented node:util API.

Node Behavior

Minimal repro:

import * as util from "node:util";

console.log(typeof util.transferableAbortController);
console.log(typeof util.transferableAbortSignal);

const controller = util.transferableAbortController();
console.log(typeof controller.abort, controller.signal.aborted);
controller.abort("done");
console.log(controller.signal.aborted, controller.signal.reason);

const ac = new AbortController();
const signal = util.transferableAbortSignal(ac.signal);
console.log(typeof signal, signal === ac.signal, signal.aborted);
ac.abort("later");
console.log(signal.aborted, signal.reason);

Node v25.9.0 prints function-shaped helpers, a controller with a live signal, and a signal that reflects later aborts:

transferableAbortController typeof: function
transferableAbortSignal typeof: function
controller abort typeof: function
controller signal aborted: false
controller signal after abort: true done
signal object: object true false
signal after source abort: true later

Perry Behavior

A focused parity probe in test-files/tmp_util_transferable_abort.ts fails to compile:

Error: `util.transferableAbortController` is not implemented in Perry — see `perry --print-api-manifest` for the supported surface, or set `PERRY_ALLOW_UNIMPLEMENTED=1` to ignore. (#463)

Report: test-parity/reports/parity_report_20260530_103958.json.

This is listed in the broad util helper tracker #2514, but it deserves a focused leaf because it is the AbortSignal/structured-clone cancellation subset rather than the unrelated debug/system-error/string-format helpers in that bucket.

Suggested PR Cut

Batch this with related issues in:
node:util: cancellation and structured-clone helper parity

Good batch candidates:

Do not batch with:

  • unrelated node:util formatting/debug/system-error helpers
  • broad worker_threads implementation work
  • general structuredClone iterator/object-shape fixes

Acceptance

  • parity/regression test proves util.transferableAbortController and util.transferableAbortSignal are function-valued exports
  • transferableAbortController() returns an AbortController-like object whose signal aborts with the supplied reason
  • transferableAbortSignal(signal) returns/marks a signal that preserves abort propagation and reason behavior like Node
  • implementation matches Node observable behavior
  • related known-failure/docs/manifest entries updated if touched

Activity

  1. andrewtdiz commented on May 30, 2026

    @andrewtdiz
    ContributorAuthor

    I’m taking this as part of the focused node:util cancellation helper PR cut with #3426 and #3427. Intended scope: expose util.transferableAbortController(), util.transferableAbortSignal(signal), and util.aborted(signal, resource), plus the minimum AbortSignal event/reason behavior needed for those helpers. Non-goals: worker_threads structured clone, stream abort semantics, and unrelated util helper APIs.

  2. andrewtdiz commented on May 30, 2026

    @andrewtdiz
    ContributorAuthor

    Opened PR #3449 for this: #3449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions