Skip to content

🐛 BUG: Regression with console.log-ing objects #3591

@Cherry

Description

@Cherry

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}' ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that isn't workingminiflareRelating to Miniflarequick winPotentially easy/straightforward issue to tackle

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions