refactor(ws): Node adapter builds WsSocket over the neutral core
Also fixes buildWsRoutes (app/index.ts) to read the pre-derived protocol/ip off the neutral WsRequest instead of req.socket, which no longer exists now that WsOpenCtx.req is WsRequest — without this every real @Ws route throws on open() and the connection hangs. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
2 files changed
+35
-99
No files matched your search
+4
-3
@@ -683,7 +683,8 @@ function buildWsRoutes(routePlans: RoutePlan[], deps: PipelineDeps): WsRouteDef[
|
||||
pattern: plan.pattern,
|
||||
open: async ({ params, inbound, abort, req }) => {
|
||||
const provided = await providedSeed(plan);
|
||||
// ws upgrades come in on the raw Node req; trustProxy derivation for ws is out of scope here
|
||||
// ws upgrades carry the neutral WsRequest (protocol/ip pre-derived by the runtime adapter);
|
||||
// trustProxy derivation for ws is out of scope here
|
||||
// context is intentionally `any`: each step merges arbitrary keys into it
|
||||
let context: any = {
|
||||
...provided,
|
||||
@@ -694,8 +695,8 @@ function buildWsRoutes(routePlans: RoutePlan[], deps: PipelineDeps): WsRouteDef[
|
||||
headers: req.headers,
|
||||
inbound,
|
||||
abort,
|
||||
protocol: (req.socket as any).encrypted ? 'https' : 'http',
|
||||
ip: req.socket.remoteAddress ?? '',
|
||||
protocol: req.protocol,
|
||||
ip: req.ip,
|
||||
};
|
||||
|
||||
for (const step of planSteps(plan)) {
|
||||
|
||||
Reference in new issue
Block a user