Skip to content

Conversation

LeTamanoir
Copy link
Contributor

@LeTamanoir LeTamanoir commented Oct 2, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved server shutdown reliability by awaiting async stop operations, ensuring graceful termination and reducing hanging connections across Bun and Web Standard environments.
  • Refactor

    • Aligned stop handlers with async behavior for consistent, predictable shutdown flow.
  • Breaking Changes

    • Public stop API now accepts an optional boolean argument (e.g., stop(true)) to control shutdown mode.

Copy link

coderabbitai bot commented Oct 2, 2025

Walkthrough

Bun and Web Standard adapters now await the underlying server's asynchronous stop operation; Bun's beforeExit handler is made async. A test was updated to call app.stop(true), indicating the stop method now accepts an optional boolean force parameter.

Changes

Cohort / File(s) Summary
Adapter stop flow updates
src/adapter/bun/index.ts, src/adapter/web-standard/index.ts
Convert stop paths to await the underlying server.stop(...). In Bun, make beforeExit handler async and await server.stop. In Web Standard, change app.server.stop(...) to await app.server.stop(...).
Tests / API usage
test/ws/aot.test.ts
Update test to call app.stop(true) instead of app.stop(), reflecting stop(force?: boolean) usage in public API.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor OS as OS/Runtime
  participant BunAdapter as Bun Adapter
  participant Server

  OS->>BunAdapter: beforeExit
  Note over BunAdapter: beforeExit is async (awaits stop)
  BunAdapter->>Server: stop(closeActiveConnections)
  activate Server
  Server-->>BunAdapter: Promise resolved
  deactivate Server
  BunAdapter-->>OS: beforeExit completes
Loading
sequenceDiagram
  autonumber
  participant App
  participant WebStdAdapter as Web Standard Adapter
  participant Server

  App->>WebStdAdapter: stop(closeActiveConnections)
  WebStdAdapter->>Server: stop(closeActiveConnections)
  activate Server
  Server-->>WebStdAdapter: Promise resolved
  deactivate Server
  WebStdAdapter-->>App: stop() resolved
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I thump my paws and gently wait,
Awaiting stops, no rush or prate—
Promises settle, sockets sleep,
Quiet burrow, calm and deep.
A rabbit nods: async complete. 🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit's high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately describes the core change of ensuring the graceful shutdown now awaits the server.stop call, matching the pull request’s modifications to asynchronous stop handling.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26c3601 and b77abcd.

📒 Files selected for processing (1)
  • test/ws/aot.test.ts (1 hunks)
🔇 Additional comments (1)
test/ws/aot.test.ts (1)

18-18: Verify stop implementation and force parameter.

Run:

#!/bin/bash
echo "=== Searching for class Elysia definition ==="
rg -nP 'class\s+Elysia\b' -C3

echo -e "\n=== Searching for stop method implementation and signature ==="
rg -nP 'stop\s*\(' -C3

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.

@LeTamanoir LeTamanoir force-pushed the fix-graceful-shutdown branch from 497b20b to d5d284d Compare October 2, 2025 21:00
@LeTamanoir LeTamanoir force-pushed the fix-graceful-shutdown branch from b17c859 to 55b7a16 Compare October 2, 2025 21:11
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.

2 participants