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(plugin-workspace-tools): properly report errors for all non-zero exit codes #6535

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

kumavis
Copy link
Contributor

@kumavis kumavis commented Oct 3, 2024

What's the problem this PR addresses?

yarn workspaces foreach [...] does not clearly indicate that there was a failure, or for what workspace there were non-zero exit codes.

Before: (just says "done", but exit code is 1)

Done in 57s 886ms

endo3 on  yarn-workspaces-for-scripts [!?] via  v18.20.4 took 58s 
❯ echo $?
1

After:

The command failed in workspace ses@workspace:packages/ses
Failed with errors in 45s 837ms

How did you fix it?

I used the report.reportError feature to report all the workspaces that had non-zero exit codes.
The final exitCode is not changed in this PR.

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

🙏 @arcanis thank you for yarn 🙏

@kumavis kumavis changed the title feat(plugin-workspace-tools): properly report errors for all non-zero exit codes fix(plugin-workspace-tools): properly report errors for all non-zero exit codes Oct 3, 2024
@kumavis kumavis force-pushed the workspaces-foreach-report-error branch from 2173691 to fab356d Compare October 3, 2024 06:13
// The order in which the exit codes will be processed is fairly
// opaque, so better just return a generic "1" for determinism.
if (finalExitCode === null)
finalExitCode = typeof errorCode !== `undefined` ? 1 : finalExitCode;
Copy link
Contributor Author

@kumavis kumavis Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we no longer need to set the finalExitCode here bc the resulting error code will be set to 1 by report.exitCode() since errors have been reported.

exitCode() {
return this.hasErrors() ? 1 : 0;
}

@kumavis kumavis marked this pull request as ready for review October 3, 2024 06:27
@kumavis
Copy link
Contributor Author

kumavis commented Oct 3, 2024

one CI failure... looks like a flakey test? unable to diagnose https://github.com/yarnpkg/berry/actions/runs/11171437408/job/31056182006

possibly related to nodejs/node#51766 ?

this unrelated recent CI run passes but logs this:

A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.

All tests are passing, but force closing the worker is failing

@kumavis kumavis force-pushed the workspaces-foreach-report-error branch from f563303 to 5cdc969 Compare October 8, 2024 03:34
@kumavis
Copy link
Contributor Author

kumavis commented Oct 8, 2024

(rebased)

@kumavis
Copy link
Contributor Author

kumavis commented Oct 8, 2024

@arcanis let me know if this PR requires any adjustments

@arcanis arcanis merged commit 718c3fc into yarnpkg:master Nov 22, 2024
25 of 26 checks passed
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.

2 participants