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

divergent behavior between node <script> and node-dev <script> #288

Open
cdaringe opened this issue Apr 16, 2022 · 7 comments
Open

divergent behavior between node <script> and node-dev <script> #288

cdaringe opened this issue Apr 16, 2022 · 7 comments

Comments

@cdaringe
Copy link

cdaringe commented Apr 16, 2022

Problem

  • node myscript.js emits events and logs, but node-dev myscript.js does not.

Reproduction

I've produced a tiny reproduction with minimal but complete instructions here: https://github.com/cdaringe/node-dev-divergent-behavior-workers#demo

  1. run without node-dev: npm run start-without-node-dev
[demo]: running worker method (type: function)
[demo]: error - logged without node-dev, not logged with node-dev Error: bummer, i'm caught in index.ts
[demo]: event - logged without node-dev, not logged with node-dev. Error: bummer, i'm caught in index.ts
  1. run with node-dev: npm start
[demo]: running worker method (type: function)

and the process exits (awaiting respawn, if respawn used)

@cdaringe
Copy link
Author

The jest-worker is using the copying execArgv (--require=/path/to/wrap.js, --experimental-loader=...), which is breaking their worker. I modified the worker source to ignore these options and it went fine :). perhaps these modules can apply a bit of defense to noop unless they are the entry processes 🤔

@cdaringe
Copy link
Author

cdaringe commented Apr 17, 2022

node-dev my-script

  • node -r wrap.js --expiremental-loader=... my-script.js { env: { IS_NODE_DEV_ENTRY: 1 } }
/* wrap.js */ 
if (IS_NODE_DEV_ENTRY) { 
  delete process.env.IS_NODE_DEV_ENTRY;  // critically, flag this file as a noop in the future!
  doTheNormalWrapStuff()
} else { 
  /* noop */ 
}

@bjornstar
Copy link
Collaborator

I cloned the repo, ran npm install then:

❯ npm run start

> dev-problemos@1.0.0 start
> node-dev --respawn index.ts

[demo]: running worker method (type: function)
[demo]: error - logged without node-dev, not logged with node-dev Error: bummer, i'm caught in index.ts
[demo]: event - logged without node-dev, not logged with node-dev. Error: bummer, i'm caught in index.ts
^C%  

I'm not seeing the behavior that you're describing.

@cdaringe
Copy link
Author

hmm. that's odd. i'm getting the same result on two different machines.

image

Maybe we could compare envs?

npx envinfo:

  System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 220.23 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 17.1.0 - /var/folders/p0/7478zjgn41scns83dcs60c7h0000gn/T/fnm_multishells/32026_1650178274430/bin/node
    Yarn: 1.22.17 - /var/folders/p0/7478zjgn41scns83dcs60c7h0000gn/T/fnm_multishells/32026_1650178274430/bin/yarn
    npm: 8.1.2 - /var/folders/p0/7478zjgn41scns83dcs60c7h0000gn/T/fnm_multishells/32026_1650178274430/bin/npm
  Managers:
    Cargo: 1.61.0 - ~/.cargo/bin/cargo
    Homebrew: 3.4.3 - /opt/homebrew/bin/brew
    pip3: 21.3.1 - /opt/homebrew/bin/pip3
    RubyGems: 3.0.3 - /usr/bin/gem
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 4.2.1 - /usr/bin/gcc
    Git: 2.30.1 - /usr/bin/git
    Clang: 13.0.0 - /usr/bin/clang
    FFmpeg: 5.0 - /opt/homebrew/bin/ffmpeg
  Servers:
    Apache: 2.4.48 - /usr/sbin/apachectl
  Virtualization:
    Docker: 20.10.12 - /usr/local/bin/docker
  IDEs:
    Nano: 2.0.6 - /usr/bin/nano
    VSCode: 1.66.1 - /opt/homebrew/bin/code
    Vim: 8.2 - /usr/bin/vim
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Bash: 3.2.57 - /bin/bash
    Perl: 5.30.2 - /usr/bin/perl
    PHP: 7.3.29 - /usr/bin/php
    Python: 2.7.16 - /usr/bin/python
    Python3: 3.9.10 - /opt/homebrew/bin/python3
    Ruby: 2.6.3 - /usr/bin/ruby
    Rust: 1.61.0 - /Users/cdaringe/.cargo/bin/rustc
  Databases:
    SQLite: 3.32.3 - /usr/bin/sqlite3
  Browsers:
    Chrome: 100.0.4896.88
    Firefox: 98.0.2
    Safari: 14.1.2

@bjornstar
Copy link
Collaborator

I'm using node v17.9.0, I tried 17.1.0 and it exhibited the same behavior you described. I don't particularly want to spend more time on debugging the issue, it works on the latest version of 16 and 17.

@cdaringe
Copy link
Author

cdaringe commented Oct 11, 2022 via email

@kherock
Copy link
Contributor

kherock commented Jan 16, 2023

@cdaringe This sounds a lot like nodejs/node#41134, which caused the following issue on Jest: jestjs/jest#12060

Try upgrading to Node.js v14.19.2, v16.14, or v17.4 if you're currently using an older version

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

No branches or pull requests

3 participants