Closed ghost closed 1 year ago
Thanks.
I made a follow up commit that moved the afterInit
call a few lines above, before we init the buffer. If afterInit
is going to fail via an error result, no point allocating that data.
As for why trying to write in init
didn't work, it's because the websocket handshake doesn't get completed until after init
returns. This is intentional, so that init
can reject the request if it wants. So if you try to write in init
, you're essentially sending the client an invalid reply to the handshake.
I needed this for my use case because I wanted to send a message to a client immediately after it connects, but I found that sending it inside the
init
hook would cause the connection to fail somehow.