`wrangler tail` with WebSockets

Is this not true for any incoming Websocket requests? - I have a console log inside of the websocket.addEventListener("message" in the websocket template on Cloudflares Github pages and I've noticed that it doesn't log those live, only when you close the connection do all the logs show up
7 Replies
NazCodeland
NazCodelandOP9mo ago
@Isaac McFadyen | YYZ01 sorry for the ping but I figure I ask you as you and I were chatting about this in the workers-discussions channel. But if anyone else knows what I can do to make those logs show up, please let me know
Isaac McFadyen
Isaac McFadyen9mo ago
Hi! Yeah no worries. So it should show those logs? Interesting that it's not. Close the connection - you mean you tail, and then hit Control C (or End on the dashboard) and they suddenly show up?
NazCodeland
NazCodelandOP9mo ago
yeah, that's what I mean see if I can get a gif going one second
NazCodeland
NazCodelandOP9mo ago
No description
NazCodeland
NazCodelandOP9mo ago
I am using this template, https://github.com/cloudflare/websocket-template, however, I have taken all of the template.js content and put it inside of a index.html and used live-server to run the index.html (sharing this incase it matters) just re-reading this, i said yes earlier but, it's not exactly what I was doing. If I close the connection like I've shown in the gif or if I change the url to another site or refresh the connection ( all those actions terminate the websocket connection )
DaniFoldi
DaniFoldi9mo ago
this is expected, websocket traces (tails) are only delivered when the connection is closed if you have long-lived connections that you want to monitor, you can either use an external service (like Axiom, Datadog, etc etc), or you can do a hack which is basically you make a request to another zone (so not with a service binding, just fetch()) and "send" your log to that worker and if you tail that auxiliary worker, you should see the logs appear quicker
NazCodeland
NazCodelandOP9mo ago
ok, thank you both.
Want results from more Discord servers?
Add your server