Repository navigation
fix: show MCPORTER_DEBUG_HANG handle dumps at the default log level - #524
KrasimirKralev wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR sends opt-in hang diagnostics through the warning logger so they appear by default on stderr. Example: Run MCPORTER_DEBUG_HANG=1 mcporter call mem.create_entities 'entities:["a"]' --output json.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open for landing: this PR fixes a documented diagnostic path that remains broken on main, with focused changes, supplied CLI proof, and no actionable findings. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe CLI inspects Node handles after tool output and around runtime shutdown, then sends diagnostic descriptions through its shared logger. flowchart TD
A[CLI tool call] --> B[JSON result on stdout]
A --> C[Runtime shutdown]
C --> D[Opt-in handle inspection]
D --> E[Shared warning logger]
E --> F[Diagnostics on stderr]
Technical reviewBest possible solution: Land the focused logger change with its CLI regression coverage and stderr documentation. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically filters the enabled info-level dumps at the default warn threshold; the contributor also supplies matching before/after CLI output, which this read-only review did not rerun. Is this the best way to solve the issue? Using the existing warning logger fixes both visibility and stream routing at their shared diagnostic owner without adding configuration or changing shutdown behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aa8d0c5ac6cd. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 25, 2026, 2:53 AM ET / 07:53 UTC. |
What Problem This Solves
When a
mcportercommand does not exit,docs/hang-debug.mdsays to setMCPORTER_DEBUG_HANG=1and read the active-handle dump. With only that variable set, the dump never appears: the handle lines are logged atinfo, and the default log level iswarn. The only line printed is the finalforcibly … childwarning, so the person debugging a hang sees nothing that names the handle keeping Node alive.Raising the level with
--log-level infobrings the dump back, butinfogoes to stdout, so the dump lands in the middle of--output jsonresults.User Impact
MCPORTER_DEBUG_HANG=1now prints the documented handle and request dump with no other flag. The dump goes to stderr, next to the existingforcibly killedbreadcrumb, so stdout keeps only the command result. Runs withoutMCPORTER_DEBUG_HANG=1print nothing new.--log-level errorstill hides these lines, as it already hid theforcibly killedline.Why This Change Was Made
The hang breadcrumbs (
dumpActiveHandlesand the tworuntime.close()timing lines) now use the samelogWarnpath as the kill breadcrumb that already showed at the default level. One line indocs/hang-debug.mdsays the diagnostics go to stderr.Evidence
Built CLI (
pnpm build,node dist/cli.js) against the repo'stests/fixtures/stdio-memory-server.mjs, withMCPORTER_DEBUG_HANG=1and no--log-level:$ MCPORTER_DEBUG_HANG=1 node dist/cli.js call --config mcporter.json mem.create_entities 'entities:["a"]' --output jsonBefore (upstream/main
aa8d0c5): exit 0, stdout{"count": 1}, stderr only:After (this branch): exit 0, stdout still only
{"count": 1}, stderr has the documented dump:On main,
--log-level infoprinted the same dump on stdout after the JSON result.Tests:
tests/cli-force-exit-behavior.integration.test.tsruns the built CLI withMCPORTER_DEBUG_HANG=1and noMCPORTER_LOG_LEVEL. It asserts stdout parses as{ ok: true }and stderr has the dump. It fails on main (stderr held only the kill line) and passes on the branch, 3 runs in a row.tests/runtime-debug.test.tsnow expects the dump on the warn logger. It fails on main and passes on the branch.pnpm check(oxfmt, oxlint, typecheck) passes.pnpm test: 2463 passed, 8 failed. All 8 failures are Bun compile cases incli-generate-cli.integration.test.ts/generate-cli.test.ts. They are a known environment failure on this machine: its Bun 1.4.0 is older than the 1.4.4 those cases need. None of them touches the files in this PR.