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
Request {

}
Request {

}
11 Replies
NazCodeland
NazCodelandOP17mo ago
doesn't show me any of the properties of the Request object I see what's going on
kian
kian17mo ago
Neither console.log or JSON.stringify handle the Web API types
NazCodeland
NazCodelandOP17mo ago
okay, that's why we have devtools option so, I need to view it in the devTools console to see those APIs thank you
Julian
Julian12mo ago
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.
Julian
Julian12mo ago
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 ?
Julian
Julian12mo ago
No description
kian
kian12mo ago
This is specific to local development, not remote development or when deployed.
Julian
Julian12mo ago
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 reply
kian
kian12mo ago
If you want to reproduce them, it just uses the util.inspect from the nodejs_compat flag. https://developers.cloudflare.com/workers/runtime-apis/nodejs/
kian
kian12mo ago
No description
Julian
Julian12mo ago
Ooh, awesome. Thanks 🙂
Want results from more Discord servers?
Add your server