-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
bugSomething that isn't workingSomething that isn't workingminiflareRelating to MiniflareRelating to Miniflarequick winPotentially easy/straightforward issue to tacklePotentially easy/straightforward issue to tackle
Description
Which Cloudflare product(s) does this pertain to?
Wrangler
What version of Wrangler are you using?
3.2.0
What operating system are you using?
Windows
Describe the Bug
Deep objects are no longer logged as previously. While not the best method of debugging, logging objects is still very useful for quick debug.
Basic Example
With the following script as worker.ts:
export default {
fetch() {
console.log({
foo: {
bar: {
baz: true
}
}
})
return new Response('ok');
}
}wrangler 2
npx wrangler@2.20.0 dev --local worker.ts
GET / 200 OK (43.86ms)
{ foo: { bar: { baz: true } } }
wrangler 3
npx wrangler@3.2.0 dev worker.ts
[mf:inf] GET /favicon.ico 200 OK (1ms)
Object {
foo: Object
}
Deeper example
In Node.js, object properties do begin to get truncated when logging deep objects, such as with this script:
export default {
fetch() {
console.log({
foo: {
bar: {
baz: {
foo: {
bar: true
}
}
}
}
})
return new Response('ok');
}
}wrangler 2 output:
{ foo: { bar: { baz: [Object] } } }
wrangler 3 output:
Object {
foo: Object
}
In node.js, the common way to solve this is using console.dir(..., {depth: null}), so when updating the script to the following:
export default {
fetch() {
console.dir({
foo: {
bar: {
baz: {
foo: {
bar: true
}
}
}
}
}, {depth: null})
return new Response('ok');
}
}wrangler 2 output:
{
foo: {
bar: { baz: { foo: { bar: true } } }
}
}
wrangler 3 output:
[ 'Object', '{\n foo: Object\n}', 'Object', '{\n depth: null\n}' ]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething that isn't workingSomething that isn't workingminiflareRelating to MiniflareRelating to Miniflarequick winPotentially easy/straightforward issue to tacklePotentially easy/straightforward issue to tackle