Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Cherry opened this issue Jul 11, 2023 · 5 comments
Closed

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

Cherry opened this issue Jul 11, 2023 · 5 comments
Labels
bug Something that isn't working miniflare Relating to Miniflare quick win Potentially easy/straightforward issue to tackle

Comments

@Cherry
Copy link
Contributor

Cherry commented Jul 11, 2023

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}' ]
@Cherry Cherry added the bug Something that isn't working label Jul 11, 2023
@JacobMGEvans
Copy link
Contributor

@mrbbot Is this related to how Miniflare handles logging with WorkerD?

@admah admah added the miniflare Relating to Miniflare label Sep 11, 2023
@AggressivelyMeows
Copy link

Is there any updates on this issue? Its been months since any updates have been given and its still a major issue when developing locally with Wrangler.

@admah admah added the quick win Potentially easy/straightforward issue to tackle label Sep 22, 2023
@admah
Copy link
Contributor

admah commented Oct 2, 2023

@Cherry thanks for filing this issue. This is definitely something we need to fix. We're going to pick this up shortly and hopefully have a resolution sometime in the next couple of weeks.

@mrbbot
Copy link
Contributor

mrbbot commented Oct 19, 2023

cloudflare/workerd#1294 has now been merged, so this should be fixed in next week's Wrangler release 👍

@Cherry
Copy link
Contributor Author

Cherry commented Oct 29, 2023

EDIT: My initial comment here was looking at the wrong thing, sorry!

This appears to be resolved now with 3.15.0, going to mark this as resolved! 🥳Thank you for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working miniflare Relating to Miniflare quick win Potentially easy/straightforward issue to tackle
Projects
None yet
Development

No branches or pull requests

5 participants