Skip to content

fix: stabilize reentrant lifecycle delivery across runners - #438

Merged
electrohyun merged 7 commits into
mainfrom
test/stabilize-cycle2-lifecycle-tests
Aug 26, 2026
Merged

electrohyun merged 7 commits into
mainfrom
test/stabilize-cycle2-lifecycle-tests

Conversation

@electrohyun

@electrohyun electrohyun commented Aug 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Tracks whether client teardown starts inside the current server packet handler. Packets that already entered middleware retain that dispatch ownership for re-entrant client.disconnect(), matching Socket.IO, while packets held before an external disconnect remain guarded.

The real fixture waits for issued client writes to leave its queue before releasing the lifecycle handler, so the middleware regression observes terminate before queued on every target. Manager ACK assertions are attached before teardown, and real Socket.IO files run serially because each owns a live server.

Twenty consecutive focused dual runs, two complete real runs, the full 1,132-case dual run, typecheck, formatting, and conformance pass locally.

Related issue

Closes #437

Checklist

  • Tests added or updated
  • Behavior verified against real socket.io

@vercel

vercel Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
smocket Ready Ready Preview Aug 26, 2026 2:36pm

@github-actions github-actions Bot added test Test coverage and fixtures 📏 s Pull request changes 10–49 lines labels Aug 26, 2026
@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f28df082-ec2c-4b22-91d4-1c89c9cdb17d

📥 Commits

Reviewing files that changed from the base of the PR and between f9463ff and df610a1.

📒 Files selected for processing (6)
  • docs/conformance.md
  • src/contracts/testing.ts
  • src/queued-delivery-lifecycle.test.ts
  • src/runtime/sockets.ts
  • src/setup-mock-server.ts
  • src/setup-real-server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/conformance.md

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The runtime now preserves packets that entered middleware before reentrant client teardown. Test fixtures provide write-drain synchronization, lifecycle tests coordinate asynchronous assertions, real-target files run serially, and conformance links use current locations.

Changes

Lifecycle Delivery Stabilization

Layer / File(s) Summary
Implement client teardown draining
src/runtime/sockets.ts, src/contracts/testing.ts, src/setup-real-server.ts, src/setup-mock-server.ts
ServerSocket tracks active dispatch ownership and preserves middleware-delayed delivery only for reentrant client teardown. Server contexts expose flushClientWrites.
Coordinate lifecycle regression tests
src/queued-delivery-lifecycle.test.ts, src/manager-disconnect.test.ts, src/disconnect.test.ts
Queued delivery waits for client writes to flush and asserts event order. Manager ACK rejection assertions are registered before teardown. The timed callback test no longer asserts a timer count.
Align test execution and references
vitest.config.ts, docs/conformance.md
Real-target test files run without file-level parallelism. Conformance links use current test locations.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to df610

The lifecycle delivery behavior is covered by the supplied validation, and no actionable merge-blocking risk remains at the current head.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ServerSocket
  participant Middleware
  Client->>ServerSocket: Handle packet
  ServerSocket->>Middleware: Enter middleware dispatch
  Client->>ServerSocket: disconnect()
  ServerSocket->>ServerSocket: Preserve active dispatch ownership
  Middleware-->>ServerSocket: Resume queued delivery
  ServerSocket-->>Client: Deliver queued packet
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: stabilizing reentrant lifecycle delivery across test runners.
Description check ✅ Passed The description directly explains the lifecycle delivery fix, fixture synchronization, ACK assertions, test serialization, and verification performed.
Linked Issues check ✅ Passed The changes address all coding objectives in [#437]: reentrant middleware delivery preservation, external-disconnect guarding, client-write flushing, pre-teardown ACK assertions, and serial execution …
Out of Scope Changes check ✅ Passed The documentation, runtime changes, fixtures, tests, and Vitest configuration all support the objectives in [#437]. No unrelated code changes are evident.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 7 files. (1 skipped: 1 …
Full details: Linked Issues check

Explanation

The changes address all coding objectives in [#437]: reentrant middleware delivery preservation, external-disconnect guarding, client-write flushing, pre-teardown ACK assertions, and serial execution for real-target tests.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 7 files. (1 skipped: 1 unsupported.)


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

@electrohyun electrohyun changed the title test: stabilize lifecycle observations across runners fix: stabilize reentrant lifecycle delivery across runners Aug 26, 2026
@github-actions github-actions Bot added bug Something isn't working 📏 m Pull request changes 50–199 lines and removed test Test coverage and fixtures 📏 s Pull request changes 10–49 lines labels Aug 26, 2026
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@electrohyun
electrohyun merged commit 0751dad into main Aug 26, 2026
17 checks passed
@electrohyun
electrohyun deleted the test/stabilize-cycle2-lifecycle-tests branch August 26, 2026 14:58
@electrohyun electrohyun self-assigned this Aug 27, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in smocket Aug 27, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in smocket Aug 27, 2026

This branch was successfully deployed

1 active deployment
Preview — df610a14 Deployed Aug 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 📏 m Pull request changes 50–199 lines

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix: stabilize reentrant lifecycle delivery across runners

1 participant