Skip to main content

Function: makeWsStubResponse()

makeWsStubResponse(onUnhandledError?): HttpResponse

Defined in: service-core/src/http/MiddlewareChain.ts:142

Builds a stub HttpResponse used for WebSocket routes: the framework middleware chain runs against a WebSocket "request" that has no real HTTP response to write to, so all writes are no-ops other than tracking writableEnded.

Parameters

onUnhandledError?

(status, payload) => void

Invoked when runChain() reaches the end of the chain with an unhandled error and falls back to res.status(...).json(...) — the only way that fallback (or any other middleware) can signal an error for a WS connection, since there is no real response to write to. The router's ws() open handler uses this to close the socket the same way route handlers do themselves (a 1002 close carrying the error's short code), instead of silently doing nothing.

Returns

HttpResponse