Strange issue with `console.log()` omitting members of objects

I'm using Itty Router with CF Workers. For some reason, when working locally and I run console.log(req) (in middleware, obviously) the vast majority of the members of that object are not shown. For example, if I run:
console.log(req)
console.log(req)
...all I get logged is:
Request {
query: Object,
params: Object,
route: *,
content: Object
}
Request {
query: Object,
params: Object,
route: *,
content: Object
}
However, if I run:
console.log(req.keepalive)
console.log(req.keepalive)
...I get:
false
false
That's just one example of missing data. There's also a Headers object that I know is there because I can call req.headers.get('my-header') and it works. Any thoughts as to what's going on here?
4 Replies
kian
kian9mo ago
query, params, route, etc aren’t part of any CF request object I know about Is this with a routing library?
Mitya
MityaOP9mo ago
I mentioned I was using Itty Router ⬆️
Kevin
Kevin9mo ago
@Mitya I have a bit more thorough description on your post in the Itty Discord, but I think the culprit is the weirdness in your export signature... you're basically creating and calling fetch on instantiation, which is sending a non-request through the router. Thus you only see the props that itty adds, and nothing from a real request. 🙂
Mitya
MityaOP9mo ago
Thank you, @Kevin | itty.dev , I'll reply over on the Itty server 👍
Want results from more Discord servers?
Add your server