Closed Dodobibi closed 2 months ago
Make a nuxt project
Define this handler in a route like server/api/testws
server/api/testws
export default eventHandler({ handler: (event) => { // Rest handler }, websocket: defineHooks({ upgrade(req) { console.log(`[ws] upgrading ${req.url}...`); }, open(peer) { console.log(`[ws] open: ${peer}`); }, message(peer, message) { console.log('[ws] message', peer, message); if (message.text().includes('ping')) { peer.send('pong'); } }, close(peer, event) { console.log('[ws] close', peer, event); }, error(peer, error) { console.log('[ws] error', peer, error); }, }), });
Upgrade hook is called, but Open is not.
Upgrade
Open
It seems than Peer have not url property, then, resolver fallback (after upgradde) from wrong hooks (at /) instead of hooks defined at the right route /api/testws in the reproduction exemple.
/
/api/testws
hooks.callHook("open", peer); ==> const resolveHooksPromise = this.options.resolve?.(arg1);
No response
nitro is not upgraded yet..
Ah, Ok, thanks 👍
Environment
Reproduction
Make a nuxt project
Define this handler in a route like
server/api/testws
Describe the bug
Upgrade
hook is called, butOpen
is not.It seems than Peer have not url property, then, resolver fallback (after upgradde) from wrong hooks (at
/
) instead of hooks defined at the right route/api/testws
in the reproduction exemple.hooks.callHook("open", peer); ==> const resolveHooksPromise = this.options.resolve?.(arg1);
Additional context
No response
Logs
No response