Skip to content
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: "Channel closed" error in child on graceful shutdown after SIGTERM #321

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"scripts": {
"ts-node-dev": "node ./lib/bin",
"build": "tsc -p tsconfig.build.json",
"prepare": "npm run build",
"release": "np",
"test": "yarn build && ts-node -T node_modules/mocha/bin/mocha test/*.test.ts",
"test-dev": "yarn ts-node-dev -T --respawn --deps --watch lib node_modules/mocha/bin/mocha test/*.test.ts --output",
Expand Down Expand Up @@ -98,4 +99,4 @@
"publishConfig": {
"registry": "https://registry.npmjs.org"
}
}
}
20 changes: 12 additions & 8 deletions src/wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,22 @@ process.on('uncaughtException', function (err: any) {
console.error((err && err.stack) || err)
}

ipc.send({
error: isTsError ? '' : (err && err.name) || 'Error',
// lastRequired: lastRequired,
message: err ? err.message : '',
code: err && err.code,
willTerminate: hasCustomHandler,
})
if (process.connected) {
ipc.send({
error: isTsError ? '' : (err && err.name) || 'Error',
// lastRequired: lastRequired,
message: err ? err.message : '',
code: err && err.code,
willTerminate: hasCustomHandler,
})
}
})

// Hook into require() and notify the parent process about required files
makeHook(cfg, module, function (file) {
ipc.send({ required: file })
if (process.connected) {
ipc.send({ required: file })
}
})

// Check if a module is registered for this extension
Expand Down