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

fix: aggregate error v4 #2631

Closed
wants to merge 4 commits into from

Conversation

hongaar
Copy link
Contributor

@hongaar hongaar commented Dec 5, 2022

This change makes utils.extractErrors compatible with aggregate-error v4, which changes its implementation to store the errors in an .errors property instead of making the Error instance iterable.

See sindresorhus/aggregate-error@02342f9

Note: could not run the linter due to Error: Cannot find module 'prettier'

@travi
Copy link
Member

travi commented Dec 9, 2022

our work toward converting the core project to esm in #2607 enables us to upgrade to aggregate-error v4. we are very close to being ready to promote that work to latest. do you see this change as being necessary after that change?

@hongaar
Copy link
Contributor Author

hongaar commented Dec 10, 2022

The change itself would still be needed but the test should probably be changed:

// This will now test for the `isFunction(err.errors[Symbol.iterator])` path
t.deepEqual(extractErrors(new AggregateError(errors)), errors);

// Add something like
// Test aggregate-error < v4 which stores errors by making object iterable
const legacyAggregateError = new Error();
legacyAggregateError[Symbol.iterator] = function* () { 
  for (const error of errors) {
    yield error;
  }
}
t.deepEqual(extractErrors(legacyAggregateError), errors);

Happy to contribute a PR once ESM support is merged.

@hongaar
Copy link
Contributor Author

hongaar commented Jan 12, 2023

Closing since latest supports aggregate-error v4. Not sure if there is value in adding backwards compatibility with earlier aggregate-error versions? May be useful when using plugins which depend on earlier versions of aggregate-error. While they won't currently break, they will not be leveraging the aggregate-error functionality. If wanted, I will reopen another PR and add the test from #2631 (comment).

@hongaar hongaar closed this Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants