You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FastifyInstance.server returns a number — blocks ws/http2 upgrade piggybacking #1113
```
typeof app.server: number
typeof app.server.on: undefined
upgrade handler threw: (number).on is not a function
```
Expected (tsx)
```
typeof app.server: object
typeof app.server.on: function
registered upgrade handler OK
```
Per Fastify docs, `app.server` is the underlying `http.Server` (or `http2.Http2Server`) — `http.Server extends EventEmitter`, so `.on("upgrade" | "connection" | ...)` is supposed to work.
How this blocks WebSocket on Fastify
The canonical way to attach `ws` (or any WS lib) to a Fastify server without opening a second port is:
That's exactly what shop-admin's `server/realtime/server.ts` does. With `app.server` being a number, the `.on` call throws at boot, the boot `catch` logs `fatal:`, the process exits. No WebSocket transport possible until `app.server` exposes the real EventEmitter handle.
Pointer
perry's fastify binding presumably has a `js_fastify_app_server` getter or similar that returns the server handle as a tagged-pointer u64 — but the runtime tag/dispatch is treating it as a number on the JS side. Either the FFI return shape needs to be NaN-boxed as an object, or codegen for the `.on` method on this handle needs to route to `js_fastify_server_on` (or equivalent) instead of generic JS `.on` dispatch.
For comparison, `reply.code(X)` was fixed in #1048 — `reply` exposed methods via codegen routing rather than property access on a returned handle. Same pattern needed for `app.server`.
Local checkout: perry 0.5.1009, no edits. Discovered while standing up envelope encryption with the #1075 AES fix landed.
Activity
fix(fastify) #1113 + chore(ffi) #1112: app.server EventEmitter (boot …
fix(fastify) #1113 + chore(ffi) #1112: app.server EventEmitter (boot …
fix(fastify) #1113 + chore(ffi) #1112: app.server EventEmitter (boot …
fix(fastify) #1113 + chore(ffi) #1112: app.server EventEmitter (boot …
fix(compile) #1110 + chore(ffi) #1112: re-export-only FFI manifest co…
chore(docs): regen API manifest docs for ws.handleUpgrade (#1113)
fix(fastify,runtime): #1113 #1114 — bidirectional WS upgrade on app.s…
fix(stdlib): real semantics or loud warn for silently-ignored adapter…
fix(stdlib): #4917 — real semantics (or loud warn) for silently-ignor…
fix(native): chained fluent method calls keep their module identity (…
fix(fastify): bound request-pump re-entrancy to avoid MAX_TRY_DEPTH
fix(fastify): bound request-pump re-entrancy to avoid MAX_TRY_DEPTH (#…