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

Node script not exiting #4054

Closed
jsefiani opened this issue Nov 7, 2020 · 2 comments · Fixed by #4083
Closed

Node script not exiting #4054

jsefiani opened this issue Nov 7, 2020 · 2 comments · Fixed by #4083
Labels
outdated scope: node Issues related to Node, Express, NestJS support for Nx type: bug

Comments

@jsefiani
Copy link

jsefiani commented Nov 7, 2020

Current Behavior

When running a NodeJS script (NX application), it keeps rebuilding when I change something in the main.ts file while watch mode is set to false (also note that my script is not exiting).
"serve": { "builder": "@nrwl/node:execute", "options": { "buildTarget": "engine:build", "inspect": false, "watch": false } },
This script connects to an FTP server, downloads some files, parses them, and interacts with a database.

It exits fine when just using node dist/apps/script/main.js but not when using nx serve script, so it's definitely not my script.

Expected Behavior

I expect my NodeJS script to run once and exit (it works when just executing node dist/apps/script/main.js).
I don't want a script to be rebuilding when I'm just running it.

Steps to Reproduce

  1. Create a NodeJS app
  2. Copy the following code in the main.ts file:
    async function main() { await new Promise((resolve, reject) => { setTimeout(() => { resolve(); }, 5000); }); }

main() .catch((err) => console.log(Something went wrong: ${err})) .finally(() => { console.log('Script executed!!'); });

  1. Go to your workspace.json and target your serve command for the NodeJS app you created and add the following options:
    "inspect": false, "watch": false

Failure Logs

No failure logs.

Environment

nx : Not Found

@nrwl/angular : Not Found
@nrwl/cli : 10.3.2
@nrwl/cypress : 10.3.2
@nrwl/eslint-plugin-nx : 10.3.2
@nrwl/express : Not Found
@nrwl/jest : 10.3.2
@nrwl/linter : 10.3.2
@nrwl/nest : 10.3.2
@nrwl/next : Not Found
@nrwl/node : 10.3.2
@nrwl/react : 10.3.2
@nrwl/schematics : Not Found
@nrwl/tao : 10.3.2
@nrwl/web : 10.3.2
@nrwl/workspace : 10.3.2
typescript : 4.0.5

@vsavkin vsavkin added the scope: node Issues related to Node, Express, NestJS support for Nx label Nov 9, 2020
@CurtisHughes
Copy link
Contributor

Ran into the same issue. I opened PR #4083 with a potential fix. The watch option is getting overwritten in the node packages' execute builder. Believe that line can just be removed.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: node Issues related to Node, Express, NestJS support for Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants