cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.7k stars 707 forks source link

🐛 BUG: `wrangler tail` doesn't report logs from Durable Objects Hibernating WebSockets API #3936

Closed jevakallio closed 10 months ago

jevakallio commented 1 year ago

Which Cloudflare product(s) does this pertain to?

Workers Runtime

What version(s) of the tool(s) are you using?

3.7.0 [Wrangler] (observed in Wrangler 2)

What version of Node are you using?

20.3.1

What operating system are you using?

Mac

Describe the Bug

When using wrangler tail, we are not able to see console.log messages from webSocketMessage, webSocketClose and webSocketError callbacks.

When NOT opting the WebSocket connection into hibernation (calling socket.accept()), we see the following tails (code below):

GET https://jevakallio-wrangler-raw.partykit.dev/ - Canceled @ 13/09/2023, 11:25:56
  (log) Durable Object constructor
  (log) NOT hibernating
  (log) webSocketConnect (fetch)
  (log) webSocketMessage: ping
  (log) webSocketMessage: ping
  (log) webSocketClose

When opting into hibernation (calling state.acceptWebSocket(socket)), we see the following tails:

GET https://jevakallio-wrangler-raw.partykit.dev/?hibernate=true - Canceled @ 13/09/2023, 11:27:59
  (log) Durable Object constructor
  (log) hibernating
  (log) webSocketConnect (fetch)

The webSocketMessage, webSocketClose and webSocketError messages are not observed in the logs, but we've verified the callbacks do run correctly.

Here's the code used to verify the behaviour. Connect with ?hibernate=true to trigger the issue, and without to demonstrate that tailing works without hibernating: https://github.com/jevakallio/wrangler-raw/blob/tails-repro/src/index.mjs

Please provide a link to a minimal reproduction

https://github.com/jevakallio/wrangler-raw/tree/tails-repro

Please provide any relevant error logs

No response

MellowYarker commented 1 year ago

Thanks for the report, we've known about this for some time https://github.com/cloudflare/workers-chat-demo/issues/34. @elithrar do you think we should add a note to the docs for now?

elithrar commented 1 year ago

https://github.com/cloudflare/cloudflare-docs/pull/10674

petebacondarwin commented 10 months ago

Closing as this is a known issue in upstream Durable Objects that is not actionable by the workers-sdk team and there is an update to the docs in flight.

MellowYarker commented 8 months ago

Just following up here, this has been fixed for some time.