Closed rxliuli closed 3 years ago
Sounds like https://github.com/yarnpkg/berry/issues/3334, do you get exit code 0 when you run it manually?
Does manual operation mean running on the wrong module? Yes, it will display a red error and terminate
No, if you run the command in your terminal instead of using this.cli.run
do you then see an exit code? Do you see an exit code other than 0 when you run the failing command outside of workspaces foreach
?
No, if you run the command in your terminal instead of using
this.cli.run
do you then see an exit code? Do you see an exit code other than 0 when you run the failing command outside ofworkspaces foreach
?
yarn workspaces foreach
$ yarn workspaces foreach --include @liuli-util/i18next-util --parallel --topological-dev run setup
➤ YN0000: (node:21180) UnhandledPromiseRejectionWarning: Error: C:/Users/rxliuli/Code/Pkg/liuli-tools/libs/i18next-util/src/index.ts(2,1): semantic error TS2304: Cannot find name 'sd'.
➤ YN0000: at error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:151:30)
➤ YN0000: at throwPluginError (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:19344:12)
➤ YN0000: at Object.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:20013:20)
➤ YN0000: at Object.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:19520:38)
➤ YN0000: at RollupContext.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:17241:30)
➤ YN0000: at C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:25064:23
➤ YN0000: at arrayEach (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:549:11)
➤ YN0000: at Function.forEach (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:9401:14)
➤ YN0000: at printDiagnostics (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:25037:12)
➤ YN0000: at Object.transform (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:30131:17)
➤ YN0000: (Use `node --trace-warnings ...` to show where the warning was created)
➤ YN0000: (node:21180) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
➤ YN0000: (node:21180) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
➤ YN0000: Done in 3s 874ms
this.cli.run
$ yarn changed foreach --include @liuli-util/i18next-util -p --topological-dev run setup
计算得到变更的模块:
@liuli-util/i18next-util
execute before: workspaces foreach --include @liuli-util/i18next-util --parallel --topological-dev run setup
➤ YN0000: (node:37240) UnhandledPromiseRejectionWarning: Error: C:/Users/rxliuli/Code/Pkg/liuli-tools/libs/i18next-util/src/index.ts(2,1): semantic error TS2304: Cannot find name 'sd'.
➤ YN0000: at error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:151:30)
➤ YN0000: at throwPluginError (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:19344:12)
➤ YN0000: at Object.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:20013:20)
➤ YN0000: at Object.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:19520:38)
➤ YN0000: at RollupContext.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:17241:30)
➤ YN0000: at C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:25064:23
➤ YN0000: at arrayEach (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:549:11)
➤ YN0000: at Function.forEach (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:9401:14)
➤ YN0000: at printDiagnostics (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:25037:12)
➤ YN0000: at Object.transform (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:30131:17)
➤ YN0000: (Use `node --trace-warnings ...` to show where the warning was created)
➤ YN0000: (node:37240) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
➤ YN0000: (node:37240) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
➤ YN0000: Done in 3s 773ms
execute after: 0
No, if you run the command in your terminal instead of using
this.cli.run
do you then see an exit code? Do you see an exit code other than 0 when you run the failing command outside ofworkspaces foreach
?
yarn workspaces foreach
$ yarn workspaces foreach --include @liuli-util/i18next-util --parallel --topological-dev run setup ➤ YN0000: (node:21180) UnhandledPromiseRejectionWarning: Error: C:/Users/rxliuli/Code/Pkg/liuli-tools/libs/i18next-util/src/index.ts(2,1): semantic error TS2304: Cannot find name 'sd'. ➤ YN0000: at error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:151:30) ➤ YN0000: at throwPluginError (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:19344:12) ➤ YN0000: at Object.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:20013:20) ➤ YN0000: at Object.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:19520:38) ➤ YN0000: at RollupContext.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:17241:30) ➤ YN0000: at C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:25064:23 ➤ YN0000: at arrayEach (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:549:11) ➤ YN0000: at Function.forEach (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:9401:14) ➤ YN0000: at printDiagnostics (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:25037:12) ➤ YN0000: at Object.transform (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:30131:17) ➤ YN0000: (Use `node --trace-warnings ...` to show where the warning was created) ➤ YN0000: (node:21180) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) ➤ YN0000: (node:21180) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. ➤ YN0000: Done in 3s 874ms
Console log executed by
this.cli.run
$ yarn changed foreach --include @liuli-util/i18next-util -p --topological-dev run setup 计算得到变更的模块: @liuli-util/i18next-util execute before: workspaces foreach --include @liuli-util/i18next-util --parallel --topological-dev run setup ➤ YN0000: (node:37240) UnhandledPromiseRejectionWarning: Error: C:/Users/rxliuli/Code/Pkg/liuli-tools/libs/i18next-util/src/index.ts(2,1): semantic error TS2304: Cannot find name 'sd'. ➤ YN0000: at error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:151:30) ➤ YN0000: at throwPluginError (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:19344:12) ➤ YN0000: at Object.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:20013:20) ➤ YN0000: at Object.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup\dist\shared\rollup.js:19520:38) ➤ YN0000: at RollupContext.error (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:17241:30) ➤ YN0000: at C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:25064:23 ➤ YN0000: at arrayEach (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:549:11) ➤ YN0000: at Function.forEach (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:9401:14) ➤ YN0000: at printDiagnostics (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:25037:12) ➤ YN0000: at Object.transform (C:\Users\rxliuli\Code\Pkg\liuli-tools\node_modules\rollup-plugin-typescript2\dist\rollup-plugin-typescript2.cjs.js:30131:17) ➤ YN0000: (Use `node --trace-warnings ...` to show where the warning was created) ➤ YN0000: (node:37240) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) ➤ YN0000: (node:37240) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. ➤ YN0000: Done in 3s 773ms execute after: 0
Looks like a problem with yarn workspaces foreach
I added a reproducible example
Steps to reproduce
git clone https://github.com/rxliuli/liuli-tools/tree/bug_yarn2_cli_run && cd liuli-tools
yarn
cd apps/liuli-cli && yarn build
cd ../.. && yarn setup
In order to see the actual executed command, I printed it out and can execute it
yarn workspaces foreach --include @liuli-util/i18next-util --parallel --topological-dev run setup
As I mentioned on Discord, your screenshot shows a warning not an error. When I run it on Node 16 I do get an error and this.cli.run
returns 1
, on Node 14 it's a warning and it returns 0
See https://nodejs.org/dist/latest/docs/api/deprecations.html#deprecations_dep0018_unhandled_promise_rejections Ref https://github.com/nodejs/node/pull/33021
As I mentioned on Discord, your screenshot shows a warning not an error. When I run it on Node 16 I do get an error and
this.cli.run
returns1
, on Node 14 it's a warning and it returns0
See https://nodejs.org/dist/latest/docs/api/deprecations.html#deprecations_dep0018_unhandled_promise_rejections Ref nodejs/node#33021
Is there a way to make it correct on nodejs 14? After all, now 14 is still a long-term support version
Yes, read the docs I linked to. This isn't a Yarn issue
Self-service
Describe the bug
When there is an error, it will not return 1
To reproduce
yarn changed foreach run build
https://github.com/rxliuli/liuli-tools/blob/586446ad046b3d5a4b3ad79c53777869131f5d4d/libs/yarn-plugin-changed/src/commands/ChangedForeachCommand.ts#L32
Environment
System: OS: Windows 10 10.0.19043 CPU: (16) x64 Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz Binaries: Node: 14.17.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.11 - C:\Program Files\nodejs\yarn.CMD npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
Additional context
No response