relay: migrate from Fastify to Bun.serve() native - #4
Merged
Conversation
Replace Fastify v5 + @fastify/websocket + ws with Bun's native HTTP and WebSocket server. Drops 62 transitive dependencies from the relay package. - Rewrite server.ts to use Bun.serve() with native WebSocket handlers - Update session.ts types for Bun's ServerWebSocket<T> - Switch tests from vitest to bun:test (relay must run under Bun runtime) - Update Dockerfile.relay: Node.js build stage + oven/bun:1.3-slim runtime - Remove fastify, @fastify/websocket, @fastify/rate-limit, ws, @types/ws - Add @types/bun for type definitions Tested: local Docker, Cloud Run deployment, health + WebSocket verified.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bun.serve()HTTP and WebSocket serveroven/bun:1.3-slimas runtime (Node.js kept for build stage only)bun:testsince the server requires Bun runtimeWhy
What changed
packages/relay/src/server.tsBun.serve()with native WebSocket handlerspackages/relay/src/session.tsServerWebSocket<WebSocketData>packages/relay/src/start.tspackages/relay/src/index.tsWebSocketDatatype exportpackages/relay/src/__tests__/bun:testpackages/relay/package.json@types/bun, test script usesbun testDockerfile.relayoven/bun:1.3-slimruntime stagepnpm-lock.yamlTest plan
bun test— all 5 relay tests pass (handshake integration + SAS computation)amesh-relay) — health + WebSocket verifiedrelay.authmesh.dev— confirmed workingpnpm build— all packages build successfully