fix: utilityProcess running user script after process.exit is called (#47469)

* fix: utilityProcess running user script after process.exit is called

* docs: update breaking changes

* chore: update spec

* chore: update spec/api-utility-process-spec.ts

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* chore: remove interface bound checks

---------

Co-authored-by: Niklas Wenzel <dev@nikwen.de>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
This commit is contained in:
Robo 2025-06-18 04:36:22 +09:00 committed by GitHub
commit 626895848e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 41 additions and 5 deletions

View file

@ -129,6 +129,26 @@ describe('utilityProcess module', () => {
expect(code).to.equal(exitCode);
});
it('does not run JS after process.exit is called', async () => {
const file = path.join(os.tmpdir(), `no-js-after-exit-log-${Math.random()}`);
const child = utilityProcess.fork(path.join(fixturesPath, 'no-js-after-exit.js'), [`--testPath=${file}`]);
const [code] = await once(child, 'exit');
expect(code).to.equal(1);
let handle = null;
const lines = [];
try {
handle = await fs.open(file);
for await (const line of handle.readLines()) {
lines.push(line);
}
} finally {
await handle?.close();
await fs.rm(file, { force: true });
}
expect(lines.length).to.equal(1);
expect(lines[0]).to.equal('before exit');
});
// 32-bit system will not have V8 Sandbox enabled.
// WoA testing does not have VS toolchain configured to build native addons.
ifit(process.arch !== 'ia32' && process.arch !== 'arm' && !isWindowsOnArm)('emits \'error\' when fatal error is triggered from V8', async () => {