Skip to content

Conversation

@SaltyAom
Copy link
Member

@SaltyAom SaltyAom commented Jul 31, 2025

Summary by CodeRabbit

  • New Features

    • Web Standard–compatible server with enhanced HTTP response handling (files, streams, content-range).
    • Built-in WebSocket support with full lifecycle events.
    • Server-Sent Events support in examples and handlers.
    • Richer server controls: hostname/port info, pending request/socket metrics, reload/ref/unref/stop utilities.
  • Documentation

    • New WebSocket server example showcasing upgrade, message, and error flows.
    • Examples updated to use OpenAPI and SSE.
  • Chores

    • Version bump to 1.4.1.
    • Dependency updates and cleanup.

@SaltyAom
Copy link
Member Author

funny thing hono node adapter has better performance than srvx, switching back leaving only crossws

@SaltyAom SaltyAom changed the title switch to srvx add crossws Jul 31, 2025
@SaltyAom SaltyAom closed this Jul 31, 2025
@SaltyAom SaltyAom reopened this Sep 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 29, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces version 1.4.1 changes: swaps server stack to srvx with crossws-based WebSocket support, adds comprehensive HTTP response mapping utilities, implements a WebSocket adapter and lifecycle integration, updates example apps (SSE + WS), and revises dependencies and changelog.

Changes

Cohort / File(s) Summary
Release notes & manifest
CHANGELOG.md, package.json
Added 1.4.1 entry; removed @hono/node-server; added srvx and crossws; updated dev deps (elysia, @elysiajs/openapi, @elysiajs/cors); added typescript, vitest; version bumped to 1.4.1-beta.0.
Examples
example/index.ts, example/demo.ts
Demo: new crossws server with full WS lifecycle handlers. Index: switched from Swagger to OpenAPI, added SSE (sse), added .ws route, tweaked GET / handler signature and logging.
HTTP response handling
src/handle.ts, src/utils.ts
Added unified response mappers (mapResponse, mapEarlyResponse, mapCompactResponse), error conversion, static handler factory, and stream handlers; introduced handleFile to normalize file/blob/stream responses with correct headers and partial content handling.
Server & WebSocket integration
src/index.ts, src/ws.ts
Reworked server bootstrap to srvx with crossws integration; added WebSocket adapter, schema validation, lifecycle (upgrade/open/message/drain/close/error), cookies handling, hooks support, and expanded server info/control API; exposed handler utilities and ws on adapter.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant S as srvx Server
  participant A as Elysia App
  participant H as Handler(mapResponse/handleFile)

  C->>S: HTTP Request
  S->>A: Route dispatch
  A-->>H: Handler output (value/stream/file/error)
  H-->>S: Response (status, headers, body)
  S-->>C: HTTP Response

  note over H,S: Supports strings, JSON, streams, files, SSE, custom statuses, errors
Loading
sequenceDiagram
  autonumber
  participant C as Client
  participant S as srvx+crossws
  participant W as WS Adapter
  participant A as Elysia WS Route
  participant RH as handleResponse

  C->>S: HTTP Upgrade (WS)
  S->>W: upgrade()
  W->>A: onOpen(context)
  A-->>C: (optional) initial messages

  loop Messages
    C->>W: message (text/binary)
    W->>A: onMessage(context, data)
    A->>RH: produce response/error
    RH-->>W: mapped WS action (send/broadcast/close)
    W-->>C: send (text/binary) or close
  end

  C-->>W: close
  W->>A: onClose(context, code/reason)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

A rabbit taps the server logs with glee,
New webs weave sockets through the elm-like tree.
Streams now sing, files glide with gentle grace,
SSEs sparkle, headers fall in place.
I thump—srvx spins, crossws twirls—hooray!
Version hops to 1.4.1 today. 🐰✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch srvx

📜 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 5a3d4e8 and f92859e.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • CHANGELOG.md (1 hunks)
  • example/demo.ts (1 hunks)
  • example/index.ts (1 hunks)
  • package.json (2 hunks)
  • src/handle.ts (1 hunks)
  • src/index.ts (2 hunks)
  • src/utils.ts (1 hunks)
  • src/ws.ts (1 hunks)

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.

@SaltyAom
Copy link
Member Author

Hono is using a custom Request, which might cause compatibility problems when using mount or an external fetch handler

We prefer compatibility first in this case

@SaltyAom SaltyAom merged commit e5b602a into main Sep 29, 2025
2 of 3 checks passed
@pi0
Copy link

pi0 commented Oct 24, 2025

Hi @SaltyAom. We had major overhauls in srvx@0.9 which added fast paths (back) for Request but it is also fully compatible with fetch(request) and new Request(request)

New benchmarks: https://github.com/h3js/srvx/tree/v0.9.0/test/bench-node

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.

3 participants