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
fix: make babel-node spawned process bubble msg #13037
fix: make babel-node spawned process bubble msg #13037
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thanks for your help with the tests @nicolo-ribaudo 👍 |
Ok it looks like I have to increase the timeout |
packages/babel-node/test/index.js
Outdated
|
||
afterEach(() => { | ||
process.chdir(cwd); | ||
const child = spawn(binLoc, [childLoc], { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.