Skip to content

fix: address CodeRabbit review findings (distZip gate, socket leak, send overload, outbox cap) - #173

Merged
sergak01 merged 1 commit into
developfrom
pp-3449-coderabbit-fixes
Jun 18, 2026
Merged

fix: address CodeRabbit review findings (distZip gate, socket leak, send overload, outbox cap)#173
sergak01 merged 1 commit into
developfrom
pp-3449-coderabbit-fixes

Conversation

@sergak01

Copy link
Copy Markdown
Contributor

Summary

Addresses 6 findings from the CodeRabbit review of PR #171, covering two production bugs, one silent data loss issue, one memory growth issue, and two test reliability fixes.


🔧 Fixes

src/cli.tsdistZip: false ignored in pp-dev next

The Vite plugin path correctly gates DistService instantiation behind distZip !== false, but the next command always created it regardless. Added distZip to the destructured ppDevConfig (default: true) and wrapped new DistService(...) in the same conditional, so template sync is properly disabled when distZip: false.

src/cli.ts — unhandled upgrade sockets left open

When neither hotServer nor nextUpgradeHandler claimed an HTTP upgrade, the socket was left open indefinitely. Added socket.destroy() in the else branch to release it immediately.

src/lib/pp-ws-server.tssend(payload) overload silently dropped messages

ViteWsFacade declares two send overloads — send(event, data?) and send(payload: unknown) — but the implementation only handled the string case. Non-string payloads were silently discarded. The payload overload now broadcasts the pre-built object as raw JSON to all connected clients, matching Vite's broadcast API.

src/client/hot-context.ts — unbounded offline outbox

Messages queued while the WebSocket was disconnected accumulated in an unbounded array, then all flushed at once on reconnect. Capped the outbox at 50 entries — oldest entry is dropped when the limit is reached.


🧪 Test reliability fixes

tests/integration/middleware/load-pp-data.spec.tsserver.close() not awaited

All four finally blocks called server.close() without waiting for the callback, causing flaky failures in parallel test runs. Promisified all four calls.

tests/integration/middleware/pp-ws-server.spec.ts — race condition in isolation test

The broadcast isolation assertion (otherReceived === false) ran immediately after the sender received its response, before the other client had a chance to process any unintended broadcast. Added a setImmediate yield to let the event loop flush before asserting.


🧪 Testing

  • npm run test:unit171 passed
  • npm run test:integration39 passed

Merge Request: origin/pp-3449-coderabbit-fixesorigin/develop

- cli(next): gate DistService instantiation behind distZip !== false, matching
  the Vite plugin path so sync is correctly disabled when distZip: false
- cli(next): destroy unhandled upgrade sockets instead of leaving them open
- pp-ws-server: implement send(payload) overload — non-string payloads were
  silently dropped; now broadcast as raw JSON like the string overload
- hot-context: cap outbox at 50 entries (drop oldest) to prevent unbounded
  memory growth during prolonged disconnects
- test(load-pp-data): await server.close() callbacks to prevent flaky parallel tests
- test(pp-ws-server): yield an event-loop tick before asserting broadcast
  isolation to eliminate the race condition in the per-client isolation test
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b49813b-9f94-483f-b8a1-b82c4ef8b5f7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pp-3449-coderabbit-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sergak01 sergak01 self-assigned this Jun 18, 2026
@sergak01
sergak01 merged commit 68d63b0 into develop Jun 18, 2026
3 checks passed
@sergak01
sergak01 deleted the pp-3449-coderabbit-fixes branch June 18, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant