WebSocket server not wired to HTTP server — issue #2 (ws payment push) is incomplete #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Issue #2 requires a WebSocket endpoint at
ws://host/api/wsso the Three.js Workshop can receive instant payment confirmations instead of polling. The event bus (lib/event-bus.ts) was created and job/session routes now publish events to it. However, no WebSocket server exists yet — nothing is listening on the bus and no clients can connect.The blocker is architectural:
artifacts/api-server/src/index.tscallsapp.listen()which returns anhttp.Server, but the reference is not captured. To attach aws.Server, we need to refactor tohttp.createServer(app)and attach the WebSocket server to the same underlying TCP port.Requirements
index.tsto usehttp.createServer(app)and store the server referencews.Server({ server, path: "/api/ws" })to the same server{ "subscribe": "job", "id": "<jobId>" }or{ "subscribe": "session", "id": "<sessionId>" }{ "type": "job:paid", "jobId": "...", "invoiceType": "eval|work" }{ "type": "job:state", "jobId": "...", "state": "..." }{ "type": "job:completed", "jobId": "...", "result": "..." }{ "type": "ping" }every 30 s; close socket if no pong within 10 sAcceptance Criteria
ws://host/api/wsaccepts WebSocket connectionsjob:paidmessage within 1 s of invoice payment (stub mode)job:completedmessage when the job finisheseventBus.listenerCount("bus"))http.createServerapproach/api/jobs,/api/ui, etc.) continue to work unchangedFiles
artifacts/api-server/src/index.ts(refactor to http.createServer)artifacts/api-server/src/lib/ws-server.ts(new — WebSocket handler)artifacts/api-server/src/lib/event-bus.ts(already created)[triage] Scope refinement:
src/index.ts(HTTP server),lib/event-bus.ts(event system)ws://host/api/wsreceivepayment_confirmedeventscurlupgrade to WS succeeds, mock payment triggers push to connected client✅ Resolved — WebSocket wired to HTTP server in index.ts (attachWebSocketServer)