oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.78k stars 2.73k forks source link

`process` is not `instanceof EventEmitter` #5121

Open NullVoxPopuli opened 1 year ago

NullVoxPopuli commented 1 year ago

What version of Bun is running?

1.0.0

What platform is your computer?

Linux 6.2.0-32-generic x86_64 x86_64

What steps can reproduce the bug?

❯ bun repl
Welcome to Bun v1.0.0
Type ".help" for more information.
[!] Please note that the REPL implementation is still experimental!
    Don't consider it to be representative of the stability or behavior of Bun overall.
> process instanceof require('node:events').EventEmitter
false

What is the expected behavior?

true

What do you see instead?

false

Additional information

In Node:

❯ node 
Welcome to Node.js v18.17.0.
Type ".help" for more information.
> process instanceof require('node:events').EventEmitter
true
old repro, not minimal ### What steps can reproduce the bug? ```bash git clone git@github.com:NullVoxPopuli/polaris-starter.git cd polaris-starter git checkout webpack-bun bun install bun --bun node_modules/.bin/ember s ``` Produces output: ``` 23 | if (_process) { 24 | throw new Error(`process already captured at: \n\n${_processCapturedLocation.stack}`); 25 | } 26 | 27 | if (outerProcess instanceof EventEmitter === false) { 28 | throw new Error('attempt to capture bad process instance'); ^ error: attempt to capture bad process instance at capture (/node_modules/ember-cli/lib/utilities/will-interrupt-process.js:28:12) at /node_modules/ember-cli/lib/cli/index.js:72:2 at /node_modules/ember-cli/lib/cli/index.js:69:33 at /node_modules/ember-cli/bin/ember:34:0 at globalThis (/node_modules/ember-cli/bin/ember:48:1) ``` ### What is the expected behavior? ember-cli's dev server boots (the `s` command) ### What do you see instead? the error posted above ### Additional information Exception occurs here: https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/will-interrupt-process.js#L28 Which can be traced - https://github.com/ember-cli/ember-cli/blob/master/lib/cli/index.js#L52 - https://github.com/ember-cli/ember-cli/blob/master/bin/ember#L34 But this is the important code: ```js willInterruptProcess.capture(options.process || process); ``` (`options.process` is undefined, so it uses the global `process`) So it seems the global `process` is not an `instanceof` EventEmitter
xhyrom commented 1 year ago

image

NullVoxPopuli commented 1 year ago

ah! thanks for the minimal repro in repl form!

NullVoxPopuli commented 1 year ago

text for me:

❯ node 
Welcome to Node.js v18.17.0.
Type ".help" for more information.
> process instanceof require('node:events').EventEmitter
true
> 
(To exit, press Ctrl+C again or Ctrl+D or type .exit)
> 
# ...
❯ bun repl
Welcome to Bun v1.0.0
Type ".help" for more information.
[!] Please note that the REPL implementation is still experimental!
    Don't consider it to be representative of the stability or behavior of Bun overall.
> process instanceof require('node:events').EventEmitter
false
> 
7heMech commented 1 year ago

Could this be related to #5163