refactor: extract runWithSignalHandling helper#2495
Conversation
Deduplicate the identical signal-handler + readline loop from streamFromContainer and tailFile into a shared runWithSignalHandling helper. Closes #2481 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors src/logs/log-streamer.ts to remove duplicated signal-handling + readline streaming logic by extracting it into a shared internal helper, improving maintainability and ensuring future changes to the cleanup lifecycle are made in one place.
Changes:
- Introduced
runWithSignalHandling(proc, formatter, parse, withPid)to encapsulate SIGINT/SIGTERM cleanup and stdout line streaming. - Updated
streamFromContainerandtailFileto delegate to the new helper after spawning the appropriate child process.
Show a summary per file
| File | Description |
|---|---|
| src/logs/log-streamer.ts | Extracts duplicated signal-handler/readline loop into runWithSignalHandling and reuses it from both container and file tailing paths. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
|
Smoke Test Results ✅ GitHub MCP: Last 2 merged PRs retrieved
✅ Playwright: github.com title verified ("GitHub" detected) Overall: PASS
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: PASS — authored by @lpcox, reviewer
|
🔥 Smoke Test Results
PR: refactor: extract runWithSignalHandling helper — author: @lpcox Overall: FAIL — smoke-data outputs were not substituted (workflow template vars unresolved), so HTTP and file tests could not be verified.
|
|
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Chroot Version Comparison Results
Overall:
|
🏗️ Build Test Suite Results
Overall: 0/8 ecosystems passed — ❌ FAIL Error: No tests were run. The workflow requires a valid
|
Smoke Test Results
Overall: FAIL —
|
Smoke Test: Gemini Engine Validation
Overall status: PASS
|
- Resolve rename conflict in docker-manager-compose.test.ts (keep split version) - Remove unused imports from docker-manager-compose.test.ts - Add parseDifcProxyHost tests to docker-manager-utils.test.ts (from #2471) - Add preserveIptablesAudit tests to docker-manager-cleanup.test.ts (from #2471) - Auto-merge log-streamer.ts refactor from #2495
Summary
Deduplicate the identical signal-handler + readline loop from
streamFromContainerandtailFileinsrc/logs/log-streamer.tsinto a sharedrunWithSignalHandlinghelper.Before
Both functions contained an identical 14-line block that:
finallyblockAfter
runWithSignalHandling(proc, formatter, parse, withPid)encapsulates this pattern. Both callers reduce to spawning the child process and delegating to the helper.Testing
Closes #2481