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
The node:execute builder immediately exits after build when --watch=false. #7031
Comments
nx/packages/node/src/executors/execute/execute.impl.ts Lines 60 to 67 in f4bc240
Something like this after these lines seems like it would probably do the trick: if (!options.watch) {
await waitForSubProcessToExit(event);
} Or maybe better, modifying async function runProcess(
event: NodeBuildEvent,
options: NodeExecuteBuilderOptions
) {
if (subProcess || !event.success) {
return;
}
subProcess = fork(event.outfile, options.args, {
execArgv: getExecArgv(options),
});
if (!options.watch) {
await new Promise((resolve, reject) => {
subProcess.once('exit', resolve);
subProcess.once('error', reject);
});
}
} One further thing that's tripping me up a bit here is we'd like to also add support for using |
@dpchamps @llwt Hey! Sorry for letting this linger so long, lets discuss this a bit and see what we think would be the best path forward. For some additional context, we are in the middle of moving a ton of logic out of @nrwl/node and @nrwl/workspace and into @nrwl/js. Part of this move will involve the executors from @nrwl/node being moved into @nrwl/js, and the build logic being rethought to introduce potential support for other tooling like SWC. I agree with @FrozenPandaz's thoughts in the PR, that the solution there seems overly complex for the description of the issue. The second code suggestion provided by @llwt seems much more lightweight, though it doesn't emit all subprocess events I'd argue that the executor doesn't need to do so.... If you want that much control its probably best to write a minimal custom executor. I do agree that the current executor shouldn't exit until the subprocess concludes, and that's a much simpler problem to tackle. Thoughts? I'm about to be on leave for the next 6 weeks, so I'm going to pull @nartc in on this discussion too, more perspectives shouldn't hurt 😄. |
Hey, is there a known workaround for this? |
I took the liberty of making a PR based on the fix in #7031 (comment), with some additional error handling. |
Hi 👋 Is there a change log / commit to reference where this was fixed? Or was it closed as a wont do? |
@nartc Thanks so much! I've asked elsewhere, but it seems that @llwt 's follow up request in this issue has largely been overlooked:
What is the best way to move forward with that request? Are there no plans to support it? It won't be possible without introducing additional complexity, but it is a desired feature that we've essentially hacked in to our build tools. It'd be great to have some support. |
@dpchamps I think it's complex enough to warrant a separate issue with a clear use-case and explanation. I personally don't truly understand the use-case just yet so it's hard for mecto respond responsibly (I'll follow up with Jack internally to see if he has any idea). That said, please feel free to open a new issue (and feel free to reference as many issues/PRs as you can in the new issue) and we'll track that as a feature request. Sounds good? |
Sounds great, thanks :D |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
The
node:execute
builder immediately exits after build when--watch=false
.Expected Behavior
The
node:execute
builder wait for the subprocess to exit, or SIGTERM to be received, before exiting. This is how things worked previously.Steps to Reproduce
Failure Logs
Environment
Node : 16.6.2
OS : darwin x64
pnpm : 6.13.0
nx : Not Found
@nrwl/angular : Not Found
@nrwl/cli : 12.9.0
@nrwl/cypress : Not Found
@nrwl/devkit : Not Found
@nrwl/eslint-plugin-nx : 12.9.0
@nrwl/express : 12.9.0
@nrwl/jest : 12.9.0
@nrwl/linter : 12.9.0
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 12.9.0
@nrwl/nx-cloud : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 12.9.0
@nrwl/web : Not Found
@nrwl/workspace : 12.9.0
@nrwl/storybook : Not Found
@nrwl/gatsby : Not Found
typescript : 4.3.5
The text was updated successfully, but these errors were encountered: