Skip to content

Options freezing breaks abort signal #2099

@svvac

Description

@svvac

The Options objects freeze the abort signal if it gets passed. As a result setting the signal prop ends up breaking the signal under node as the builtin code sets private properties when calling AbortController.abort().

This makes it impossible to pass a default abort signal to a Got instance as the runtime will throw when aborting.

  • NodeJS v16.15.1
  • Got v12.3.0
import got from 'got';
const abortCtrl = new AbortController();
const got2 = got.extend({
    signal: abortCtrl.signal,
});
abortCtrl.abort();
$ node test.mjs
node:internal/abort_controller:279
  signal[kAborted] = true;
                   ^

TypeError: Cannot assign to read only property 'Symbol(kAborted)' of object '#<AbortSignal>'
    at abortSignal (node:internal/abort_controller:279:20)
    at AbortController.abort (node:internal/abort_controller:315:5)
    at file:///tmp/test.mjs:6:11
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions