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

ReferenceError: AggregateError is not defined on attempting to bump to 0.30.0 #3158

Closed
6 tasks done
trivikr opened this issue Apr 9, 2023 · 6 comments · Fixed by #3171
Closed
6 tasks done

ReferenceError: AggregateError is not defined on attempting to bump to 0.30.0 #3158

trivikr opened this issue Apr 9, 2023 · 6 comments · Fixed by #3171
Assignees

Comments

@trivikr
Copy link
Contributor

trivikr commented Apr 9, 2023

Describe the bug

The following error is thrown when attempting to bump vitest to v0.30.0

⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯
ReferenceError: AggregateError is not defined
 ❯ Object.runTests node_modules/vitest/dist/vendor-cli-api.c04eaa34.js:7257:11
 ❯ Object.runTests node_modules/vitest/dist/vendor-cli-api.c04eaa34.js:7396:5
 ❯ async file:/home/runner/work/aws-sdk-js-codemod/aws-sdk-js-codemod/node_modules/vitest/dist/vendor-cli-api.c04eaa34.js:13913:9
 ❯ Vitest.runFiles node_modules/vitest/dist/vendor-cli-api.c04eaa34.js:13927:12
 ❯ Vitest.start node_modules/vitest/dist/vendor-cli-api.c04eaa34.js:13836:5
 ❯ startVitest node_modules/vitest/dist/vendor-cli-api.c04eaa34.js:[20](https://github.com/awslabs/aws-sdk-js-codemod/actions/runs/4652038000/jobs/8232008884?pr=483#step:7:21)784:5
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
 ❯ start node_modules/vitest/dist/cli.js:106:17

Reproduction

GitHub CI failure: https://github.com/awslabs/aws-sdk-js-codemod/actions/runs/4652038000/jobs/8232008884?pr=483

System Info

The issues happens on macOS as well as GitHub CI.

  System:
    OS: macOS 13.2.1
    CPU: (8) x64 Apple M1 Pro
    Memory: 40.89 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.21.3 - ~/Library/Caches/fnm_multishells/74988_1681066077026/bin/node
    Yarn: 3.5.0 - ~/Library/Caches/fnm_multishells/74799_1681066062748/bin/yarn
    npm: 6.14.18 - ~/Library/Caches/fnm_multishells/74988_1681066077026/bin/npm
    Watchman: 2022.08.15.00 - /opt/homebrew/bin/watchman
  npmPackages:
    vitest: ^0.30.0 => 0.30.0 

Used Package Manager

yarn

Validations

@trivikr
Copy link
Contributor Author

trivikr commented Apr 9, 2023

The line of code which throws error:

throw new AggregateError(errors, 'Errors occurred while running tests. For more information, see serialized error.')

Probably related to #3103

@trivikr
Copy link
Contributor Author

trivikr commented Apr 9, 2023

This could be happening as AggregateError support was added in Node.js 15.x+ with v8 8.6
https://nodejs.org/en/blog/release/v15.0.0#v8-86---35415

Do thread.ts need to import AggregateErrorPonyfill from utils?

import type { AggregateError as AggregateErrorPonyfill } from '../../utils'

@trivikr
Copy link
Contributor Author

trivikr commented Apr 10, 2023

I replaced AggregateError with Error and the error changed to:

ReferenceError: performance is not defined

The performance is not global in Node.js 14.x, and requires import from perf_hooks.
Looks like either performance was added in vitest source code without import from perf_hooks somewhere between versions 0.29.8 and 0.30.0, or some bundler configuration was updated.

@trivikr
Copy link
Contributor Author

trivikr commented Apr 10, 2023

This could be related to adding custom isNodeBuiltin API call in #2766

@trivikr
Copy link
Contributor Author

trivikr commented Apr 10, 2023

I noticed performance is imported from perf_hooks in the source code in vitest and vite-node workspaces.

And the import was missed in https://github.com/vitest-dev/vitest/pull/3103/files#diff-1dd42957b6a1b54eefc60f69188d482af54ba3cd308a166e2ce9f970ed784b41, in file which contains v8 import from node:v8

I posted a fix in #3159.
Feel free to cherry-pick it, and add tests. I think we'll need a v0.30.1 release.

@ST-DDT
Copy link
Contributor

ST-DDT commented Apr 11, 2023

v0.30.1 fixed the issue for us. Thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Jun 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants