Cloudflare DevelopersCD
Cloudflare Developers6mo ago
19 replies
gekkepop.

Invalid WebSocket close code: 1006.

Somehow my websocket closes after 1 minute of inactivity, I don't really understand why, since I am letting the durable object hibernate and this should NOT close the websocket. Any ideas what I am doing wrong?

More of my error:

message:

"Invalid WebSocket close code: 1006.",
exception:
{
stack:

" at WebSocketHibernationServer.webSocketClose (index.js:65:8)",
name:

"TypeError",
message:

"Invalid WebSocket close code: 1006.",
timestamp:

1754763792033,
},

But if I look at my code, webSocketClose only has this:
async webSocketClose(ws, code, reason, wasClean) {
// If the client closes the connection, the runtime will invoke the webSocketClose() handler.
ws.close(code,
Durable Object is closing WebSocket because ${reason}, it ${wasClean ? '' : "didn't"} close cleanly
);
}

So this doesn't make any sense to me, any help is greatly appreciated.
Was this page helpful?