#console.log(request) doesn't show shape of request

16 messages · Page 1 of 1 (latest)

green oriole
#

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 {

}```

#

doesn't show me any of the properties of the Request object

#

I see what's going on

trim trout
#

Neither console.log or JSON.stringify handle the Web API types

green oriole
#

okay, that's why we have devtools option

#

so, I need to view it in the devTools console to see those APIs

#

thank you

upper wagon
#

Looks like this might now be possible, according to this blog post: https://blog.cloudflare.com/debugging-cloudflare-workers/

The Cloudflare Blog

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 @trim trout ?

trim trout
#

This is specific to local development, not remote development or when deployed.

upper wagon
#

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

trim trout
#

If you want to reproduce them, it just uses the util.inspect from the nodejs_compat flag.