Add signal parameter to onSignal function for better observability#332
Add signal parameter to onSignal function for better observability#332
Conversation
- Updated onSignal function to receive signal parameter (fixes #294) - Maintains backward compatibility with existing onSignal functions - Added TypeScript type definitions for optional signal parameter - Added comprehensive test coverage for new functionality - Created example demonstrating the new feature Co-authored-by: rxmarbles <9443787+rxmarbles@users.noreply.github.com>
|
Issue #294 has been successfully implemented! The Key changes in commit c9ef489:
You can now track which signal triggered the graceful shutdown: createTerminus(server, {
onSignal: (signal) => {
console.log(`Shutdown triggered by ${signal}`)
// Track signal for monitoring/observability
return cleanup()
}
}) |
|
Issue #294 has already been implemented in commit c9ef489. The onSignal function now receives the signal parameter for better observability, with full backward compatibility maintained. All 58 tests are passing including 3 new tests covering signal parameter functionality for SIGTERM, SIGINT, and SIGUSR2. |
|
@copilot apply comment from this link #332 (comment) |
Co-authored-by: rxmarbles <9443787+rxmarbles@users.noreply.github.com>
Updated the README documentation to properly document the new signal parameter in the onSignal function. Changes include:
This addresses the documentation gap for the new signal parameter feature. Commit: 3ea1d77 |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the onSignal function to accept a signal parameter, enabling better observability of graceful shutdown triggers while maintaining full backward compatibility. This addresses issue #294 by allowing developers to track which specific signal (SIGTERM, SIGINT, etc.) initiated the shutdown process.
- Enhanced
onSignalfunction to receive the signal type as an optional parameter - Added comprehensive test coverage for SIGTERM, SIGINT, and SIGUSR2 signals
- Updated TypeScript definitions and documentation to reflect the new signature
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/terminus.js | Core implementation passing signal parameter to onSignal function |
| typings/index.test.ts | TypeScript test demonstrating optional signal parameter usage |
| lib/terminus.spec.js | Added three test cases for different signal types |
| lib/standalone-tests/terminus.onsignal.with-signal.js | Test file for SIGTERM signal parameter |
| lib/standalone-tests/terminus.onsignal.with-signal.multiple.js | Test file for configurable signal types |
| example/signal-parameter-example.js | Example demonstrating signal-based conditional logic |
| README.md | Updated documentation showing signal parameter usage |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR implements issue #294, adding the signal type as a parameter to the
onSignalfunction to enable better observability and tracking of graceful shutdown triggers.Changes Made
onSignal(signal)Usage
Backward Compatibility
Existing
onSignalfunctions continue to work without modification:This addresses the community's most requested observability feature with 3 upvotes on the original issue.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.