console.log(request) doesn't show shape of request
Hey everyone, I have a local environment running,
wrangler dev
In my worker script, I have console.log(request)
and in the terminal all I see is 11 Replies
doesn't show me any of the properties of the Request object
I see what's going on
Neither console.log or JSON.stringify handle the Web API types
okay, that's why we have devtools option
so, I need to view it in the devTools console to see those APIs
thank you
Looks like this might now be possible, according to this blog post: https://blog.cloudflare.com/debugging-cloudflare-workers/
The Cloudflare Blog
Better debugging for Cloudflare Workers, now with breakpoints
We provide many tools to help you debug Cloudflare Workers; from your local environment all the way into production. In this post, we highlight some of the tools we currently offer, and do a deep dive into one specific area - breakpoint debugging - a tool we recently added into our workerd runtime.
Although it's not clear to me how they're generating the nice logs of the
request
value in the blog post — they don't say, they simply mention console.log
. Any ideas @kian ?This is specific to local development, not remote development or when deployed.
Huh, yeah, I was just about to say — the logs don't work when running
wrangler dev --remote
, even when making the requests against localhost
. Must be that.
Thanks for the replyIf you want to reproduce them, it just uses the
util.inspect
from the nodejs_compat
flag.
https://developers.cloudflare.com/workers/runtime-apis/nodejs/Ooh, awesome. Thanks 🙂