Closed e3dio closed 1 year ago
Nevermind works fine sorry I had wrong code
Maybe you were on an older version? It was broken before
Not sure but is good now, this is my current upgrade handler:
app.ws('/ws', {
upgrade: auth({ new: true }, (res, context) => {
res.cork(() => {
if (res.setCookie) res.writeStatus('101').writeHeader('Set-Cookie', res.setCookie);
res.upgrade({ user: res.user }, ...res.wsHeaders, context);
});
})
})
That looks good but you shouldn't need to call cork since you are executing inside upgrade handler which already is default corked. But it doesn't harm but still
Oh wait you posted this as an example for failure my brain just locked up ńvm
the auth
middleware is async so it needs to cork
Oh, cool!
That usage looks pretty nice, clean and simple and now with proper corking you get a gold star ⭐
after async calling res.cork(() => { res.writeStatus('101').writeHeader('test', '123'); res.upgrade(...); }) fails. If you separate the res.upgrade into its own cork it works