Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"AbortController is not defined" error on Node 14 #630

Closed
vlukashov opened this issue Feb 14, 2023 · 2 comments · Fixed by #741
Closed

"AbortController is not defined" error on Node 14 #630

vlukashov opened this issue Feb 14, 2023 · 2 comments · Fixed by #741
Labels
bug Something isn't working

Comments

@vlukashov
Copy link

vlukashov commented Feb 14, 2023

Describe the bug
Running any CLI based on @oclif/core 2+ on Node 14 consistenly fails with "ReferenceError: AbortController is not defined" in some cases.

To Reproduce
Steps to reproduce the behavior:

  1. create a new oclif CLI with npx oclif generate my-oclif-core2-cli
  2. install the latest Node 14 with nvm install 14 && nvm use 14
  3. run the hello command when the terminal is not interactive: head -n1 package.json | bin/dev hello -f NodeJS
  4. See the error
ReferenceError: AbortController is not defined
    at /path/to/my-oclif-core2-cli/node_modules/@oclif/core/lib/parser/parse.js:28:20
    at new Promise (<anonymous>)
    at readStdin (/path/to/my-oclif-core2-cli/node_modules/@oclif/core/lib/parser/parse.js:26:12)
    at Parser._args (/path/to/my-oclif-core2-cli/node_modules/@oclif/core/lib/parser/parse.js:275:35)
    at Parser.parse (/path/to/my-oclif-core2-cli/node_modules/@oclif/core/lib/parser/parse.js:161:43)
    at Object.parse (/path/to/my-oclif-core2-cli/node_modules/@oclif/core/lib/parser/index.js:18:33)
    at Hello.parse (/path/to/my-oclif-core2-cli/node_modules/@oclif/core/lib/command.js:193:38)
    at Hello.run (/path/to/my-oclif-core2-cli/src/commands/hello/index.ts:28:40)
    at Hello._run (/path/to/my-oclif-core2-cli/node_modules/@oclif/core/lib/command.js:107:33)

Expected behavior
The CLI should produce the same output on Node 14 as it does on Node 16 or newer:

$ head -n1 package.json | bin/dev hello -f NodeJS
hello { from NodeJS! (./src/commands/hello/index.ts)

Screenshots
image

Environment (please complete the following information):

  • MacOS Monterey
  • zsh 5.8.1

Additional context
The root cause seems to be in using the AbortController API assuming that it's always available. However, this API was added in Node 15 and is not available in Node 12 and 14. Since oclif claims to support Node 12+ it should either load an AbortController API polyfill or stop using this API.

tylerbutler added a commit to microsoft/FluidFramework that referenced this issue Mar 2, 2023
oclif released a new version; this PR upgrades the build-tools projects
that use oclif to the latest.

Most notable improvements for us:

- Simplifies typing in inherited classes.
- More consistent handling of args -- they're handled like flags now.
- ESM-ready, but will wait to switch to ESM until we're using node 16.

I also set the NODE_OPTIONS='--experimental-abortcontroller' environment
variable as a workaround for oclif/core#630 in
Node 14.

More upgrade info at
https://github.com/oclif/core/blob/main/MIGRATION.md.
@shazron
Copy link

shazron commented Jul 17, 2023

It looks like version 2.9.x of @oclif/core does not support node-14 anymore, without making it a major version bump. See #737

@mshanemc @jdxcode

@mdonnalley mdonnalley added the bug Something isn't working label Jul 25, 2023
@git2gus
Copy link

git2gus bot commented Jul 25, 2023

This issue has been linked to a new work item: W-13823076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants