Enhances error logging for process cleanup#303
Open
davidgs wants to merge 2 commits into
Open
Conversation
✅ Deploy Preview for elaborate-kangaroo-25e1ee ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Errors encountered during server shutdown and process termination in the link checker script were previously caught and silently ignored. This change adds `console.error` calls to these catch blocks to log the specific error messages. This improves debuggability by providing visibility into potential issues during cleanup operations without altering the script's existing error handling logic. Signed-off-by: David G. Simmons <santafen@mac.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the debuggability of the scripts/check-links.mjs cleanup path by adding additional console error logging when server/process termination attempts fail.
Changes:
- Log error messages when killing a process on the configured port fails during forced shutdown.
- Log error messages when killing the server process group or main process fails (SIGTERM/SIGKILL paths).
- Log error messages when killing a PID discovered via
lsoffails.
Comments suppressed due to low confidence (2)
scripts/check-links.mjs:155
- Same as above: failures to signal the process group / process can be an expected state during shutdown (already-exited process =>
ESRCH). Consider filtering expected error codes or lowering the log level so routine cleanup doesn’t emit scary error output.
// Negative PID kills the process group
process.kill(-serverProcess.pid, 'SIGTERM');
} catch (e) {
console.error('Error killing process group:', e.message);
// Fallback to killing just the main process if process group fails
try {
serverProcess.kill('SIGTERM');
} catch (e2) {
console.error('Error killing main process:', e2.message);
// Process might already be dead, that's fine
scripts/check-links.mjs:183
- When
process.kill()fails because the PID is already gone (ESRCH), that’s typically not actionable here and will now be logged as an error. Consider filtering expected error codes and include the PID in the log (and/or log the full error object) for unexpected failures to make the output more useful.
try {
process.kill(parseInt(pid), 'SIGKILL');
} catch (e) {
console.error('Error killing process:', e.message);
// Process might already be dead
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: David G. Simmons <davidgs@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds more specific error logging to
stopServerandkillProcessOnPortfunctions within the link checking script. When attempts to kill processes or process groups fail, thee.messageis now logged to the console, providing more context about the error.Why is this change needed?
This change improves the debuggability of the link checking script. By logging detailed error messages when process termination fails, it becomes easier to identify and troubleshoot issues related to orphaned processes or server shutdown failures during the cleanup phase.
How was this tested?
npm test)npm run build)npm start)Checklist
git commit -s) per DCOnpm test)npm run build)Related Issues