fix: make babel-node spawned process bubble msg#13037
fix: make babel-node spawned process bubble msg#13037nicolo-ribaudo merged 2 commits intobabel:mainfrom lambertkevin:bugfix/make-subprocess-event-propagate
Conversation
|
Couldn't really find out the process to create the test yet. But this would make it successful:
const { spawn } = require('child_process');
const child = spawn('babel-node', ['child.js'], {
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
});
child.on('message', (msg) => {
expect(msg).to.be.equal('hello');
done();
});
process.send('hello'); |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 2562c01:
|
|
Thanks! I can try working on a test based on your code. |
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/44576/ |
|
@nicolo-ribaudo I squashed the typo and a linting error. I might need some help to understand the EDIT: Ok nvm, looks like it passed this time 🤷♂️ |
|
Test added! It's indeed failing without your change. For reviewers: please review my commit separately, since one only renames files but git doesn't properly track the rename when viewing the commit together. |
Thanks for your help with the tests @nicolo-ribaudo 👍 |
|
Ok it looks like I have to increase the timeout |
|
|
||
| afterEach(() => { | ||
| process.chdir(cwd); | ||
| const child = spawn(binLoc, [childLoc], { |
There was a problem hiding this comment.
The shebang in bin/babel-node may not work on Windows, consider invoke babel-node via node.
|
The windows test is failing with https://stackoverflow.com/questions/63303200/node-child-process-spawn-bad-file-descriptor-on-windows-with-ipc 🤔 |
* Add ipc test Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
|
Thanks @nicolo-ribaudo @JLHwung |
|
Thanks for the fix! |
Just linked the subprocess messages events to the process.send in order to bubble the event and make it listenable when spawning a subprocess with babel-node.