test: nested object literal must not corrupt an adjacent native (WS) handle - #5701
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Rust regression test that compiles an inline TypeScript WebSocket echo program, runs the resulting binary with a timeout watchdog, and asserts the echoed output. ChangesNested WebSocket inbound regression test
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/perry/tests/nested_object_literal_ws_inbound.rs`:
- Around line 123-127: The success path in the inbound WebSocket test relies on
`ws.close()` and `server.close()` to naturally drain the event loop, which can
stall after `WSOK` is logged. Update the cleanup in the `message` handler to
make completion deterministic by explicitly finishing the test once the expected
`"echo:ping"` message is received, using the existing `timer`, `ws`, and
`server` cleanup path without depending on asynchronous close completion.
- Around line 55-57: The test fixture in nested_object_literal_ws_inbound.rs is
discarding stderr from the spawned Command, which hides the fixture’s own
failure message on both error and timeout paths. Update the child process setup
for Command::new(bin) so stderr is captured instead of sent to Stdio::null(),
and then read or surface that stderr in the test flow that uses child so
failures remain diagnosable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 502030e8-e8f7-4ad2-bfce-6401d8532914
📒 Files selected for processing (1)
crates/perry/tests/nested_object_literal_ws_inbound.rs
de5f5f9 to
78f02a1
Compare
|
Addressed the two review comments:
Also ran The |
…handle
Regression guard for a codegen bug present in v0.5.1206: a deeply nested
object/array literal at module scope -- {a:[..],b:[{kind,child:{a:[..],
b:[{kind}]}}]}, an object whose array element holds a nested object that itself
holds an array of objects -- silently broke node:http WebSocket INBOUND
dispatch globally: the upgrade handler's wsId.on("message") never fired while
outbound wsId.send(...) still worked. The literal read back fine; the
corruption hit a neighbouring allocation (the WS client handle). A flat,
single-level literal was unaffected. Fixed after v0.5.1206; this test guards
the regression.
The fixture self-tests in-process: a WS echo server + a ws client that sends
"ping" and expects "echo:ping". A miscompile -> no echo -> hang; a healthy
build -> prints WSOK and exits 0.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
781b910 to
3e7bbc1
Compare
Summary
Adds a regression test for a codegen bug — present on
v0.5.1206, fixed since — where a deeply nested object/array literal at module scope corrupted an adjacent native handle: it silently brokenode:httpWebSocket inbound dispatch globally (the upgrade handler'swsId.on("message", …)stopped firing) while outboundwsId.send(...)kept working. The literal itself read back correctly — the corruption hit a neighbouring allocation (the WS client handle), so the only observable was the dropped inbound frame. A flat, single-level literal was unaffected.Changes
crates/perry/tests/nested_object_literal_ws_inbound.rs: a self-testing compile+run regression test, modeled on the existingissue_5174_headers_http_pump_hang.rs. The fixture defines a nested literal of the shape{ a: [..], b: [{ kind, child: { a: [..], b: [{ kind }] } }] }, stands up anode:httpWS echo server, connects awsclient to it in-process, and asserts theping→echo:pinground-trip. A healthy build printsWSOKand exits 0; a miscompile drops the inbound frame and hangs — caught by both the Rust wall-clock timeout and the fixture's own 8sexit(1).Related issue
n/a — standalone regression guard (the underlying bug is already fixed on
main).Test plan
Verified the fixture compiles and completes the WS round-trip on a current
mainbuild:cargo build --releaseclean (-p perry, offmain)cargo test --workspace …— the new#[test]follows the establishedissue_5174compile+run+timeout pattern; I verified the fixture's behavior directly (above) but left the full workspace test run to CI#[test]in the affected crate (crates/perry/tests/)Screenshots / output
Fixture stdout on a healthy build:
Checklist
feat:/fix:/docs:/chore:prefix convention (test:)Summary by CodeRabbit