-
Notifications
You must be signed in to change notification settings - Fork 774
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
[Miniflare 3] Problems with the new logs #4357
Comments
Hey! 👋 Thank you very much for the detailed feedback! 😃 As you point out, For
|
Thanks for the quick response!
I'd consider this a feature since right now we are manually muting certain workerd logs that are not actionable -- e.g.
Yay. Not sure the best way to contribute right now since PRs are frozen here cloudflare/miniflare#728 . Or maybe you want to implement this yourself since you have more context on Wrangler/etc to ensure the feature is flexible enough. Perhaps something to keep in mind: if sourcemap support ends up implemented in the default
Yeah, as mentioned, it's probably not Miniflare's business. We do include prefixes for well-known errors and warnings so we can just detect that with regexps (as long as they are logged within the same console call 😆 ). |
Hey! 👋 I'm going to transfer this to |
Hi 👋
Thanks a lot for the effort on improving console logging in workerd/Miniflare. Here's some feedback on that feature.
I'm making a CLI for Shopify/Hydrogen apps and, before this feature was released, we relied on inspector connections to get the console logs -- very similar to what Wrangler does but without ink/React, adding sourcemaps, and logging Error objects with
cause
. Also, we currently overwriteconsole.error
and other methods in the CLI process to enhance well-known errors and warnings. For example, we show a link to a local GraphiQL if the error has certain information in itscause
property:The new console logging is now enabled by default so I could try disabling the custom implementation based on inspector protocol. However, here are some issues I've found:
Each string line is logged in its own
console.log
call.For example, calling
console.log('first\nsecond')
in-app will turn into 2 separate calls toconsole.log
in Miniflare, one per line. This is because Miniflare uses thereadline
module to pipe logs.This makes it impossible for us to detect and replace known warnings and errors at the CLI level because they are now split in different console calls.
On top of that,
console.warn
andconsole.error
come with red color. I think it would be better if Miniflare didn't have any opinion on how these things are printed:But I'm not sure if that would break anything in Wrangler. It should still work with Ink since it's turned into console.log calls -- and I think this is a good thing, it's more similar to the in-app code that also calls console.log.
Otherwise, maybe
pipeOutput
could be an optional parameter in Miniflare?Logged errors and objects are stringified
This is likely something that Miniflare shouldn't care but still mentioning it here just in case. Since everything comes stringified from workerd and is passed as a string to
console
, we are not able to detect Error objects anymore and read properties such asError.cause
orError.stack
.In our current implementation using the inspector, we reconstruct the Error object before calling
console.error
in the CLI process. We could always change our CLI to use regexps and find the stringified{ [cause]: ... }
, of course, so it's not the end of the world.Logged errors don't use sourcemaps
Probably similar to cloudflare/miniflare#729 but unsure if that one was for Miniflare 3 or 2.
As mentioned, logged errors with
console.error
seem to be stringified in workerd and then streamed to the Miniflare process. Since workerd doesn't implement sourcemaps (afaik), we don't get nice stack traces. This could probably be implemented again around thepipeOutput
function since Miniflare is actually aware of sourcemaps.In our current implementation using the inspector, we are able to add sourcemaps directly there before calling
console.error
.Can't disable the new console logging feature
While some of the previous issues are fixable, I think it would be nice to provide an option to simply disable console logging from the app so that we can keep relying on the inspector protocol until everything works well.
For now, we'll probably keep using an older version of Miniflare that doesn't have the console logging feature 👍
The text was updated successfully, but these errors were encountered: