Skip to content

[Workers] [WebSocket Helper] Error after disconnecting when client sent a message #4603

@JustJoostNL

Description

@JustJoostNL

What version of Hono are you using?

4.11.3

What runtime/platform is your app running on? (with version if possible)

Cloudflare Workers

What steps can reproduce the bug?

hono.get(
  "/ws",
  upgradeWebSocket((c) => ({
    onMessage: async (ev: MessageEvent, ws) => {
      ws.send("hi");
    },
  })),
);
  1. Connect to the websocket.
  2. Send a message to the server as client.
  3. Observe the hi response.
  4. Disconnect the websocket.
  5. Observe the Cloudflare Workers error: Uncaught Error: The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response. Refer to: https://developers.cloudflare.com/workers/observability/errors/.

What is the expected behavior?

When disconnecting after sending a message it should not show that error. Interestingly, when connecting, and disconnecting right after without sending a message, it works fine.

What do you see instead?

The following unexpected Cloudflare Workers error: Uncaught Error: The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response. Refer to: https://developers.cloudflare.com/workers/observability/errors/.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions