Skip to content

Commit

Permalink
fix: infinite worker process spawned for invalid JS file
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirMikulic authored and manast committed Feb 11, 2023
1 parent f9e6ad3 commit a445ba8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/classes/child-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getFreePort = async () => {
return new Promise(resolve => {
const server = createServer();
server.listen(0, () => {
const { port } = (server.address() as AddressInfo);
const { port } = server.address() as AddressInfo;
server.close(() => resolve(port));
});
});
Expand Down Expand Up @@ -121,8 +121,13 @@ export class ChildPool {
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);

await initChild(child, child.processFile);
return child;
try {
await initChild(child, child.processFile);
return child;
} catch (err) {
_this.release(child);
throw err;
}
}

release(child: ChildProcessExt): void {
Expand Down

0 comments on commit a445ba8

Please sign in to comment.