Skip to content

node:util: implement aborted AbortSignal promise helper #3426

Closed

Description

@andrewtdiz

Summary

util.aborted(signal, resource) should return a Promise that settles when an AbortSignal aborts. Perry currently rejects the helper at compile time as an unimplemented node:util API.

Node Behavior

Minimal repro:

import * as util from "node:util";

const controller = new AbortController();
const promise = util.aborted(controller.signal, {});
console.log("aborted typeof:", typeof util.aborted);
console.log("promise:", promise instanceof Promise);

promise.then((event: any) => {
  console.log("resolved event:", event?.type, event?.target === controller.signal);
});

controller.abort("done");
await promise;

Node v25.9.0 prints:

aborted typeof: function
promise: true
resolved event: abort true

Perry Behavior

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

Error: `util.aborted` 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_104857.json.

This is listed in the broad util helper tracker #2514, but it belongs with the focused AbortSignal helper work rather than unrelated util formatting/debug/system-error helpers.

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
  • stream pipeline abort semantics
  • broad worker_threads implementation work

Acceptance

  • parity/regression test proves util.aborted is a function-valued node:util export
  • util.aborted(signal, resource) returns a Promise
  • aborting the signal resolves the Promise with the Node-shaped abort event
  • 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 #3419 and #3427. Intended scope: implement util.aborted(signal, resource) with Node-shaped Promise resolution on abort, alongside the transferable AbortSignal helpers and the minimum signal event/reason behavior they share. Non-goals: stream pipeline 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