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

Log warnings directly to stderr locally #1444

Merged
merged 1 commit into from
Nov 28, 2023
Merged

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Nov 28, 2023

Hey! 👋 With #1294, console.log()s are now logged directly to stdio when running locally. This means Wrangler no longer uses the V8 inspector to receive log messages. Unfortunately, this means we're were missing out on some warnings from workerd. This change logs those warnings directly to stderr too if we're running locally.

Ref: cloudflare/workers-sdk#4512

@mrbbot mrbbot requested review from a team as code owners November 28, 2023 12:10
KJ_LOG(INFO, "console warning", description);
} else {
fprintf(stderr, "%s\n", description.cStr());
fflush(stderr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stderr is unbuffered, fflush probably isn't helping here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that initially too, but when spawning workerd from Node and piping the output to a stream, it looks like you need explicit flushes. See #1343.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I thought it was buffered too, that's surprising. An alternative might be to use setvbuf()/setlinebuf() to enable line buffering for stderr, but that would affect it outside of this scope too.

@mrbbot mrbbot merged commit 37fce2b into main Nov 28, 2023
11 checks passed
@mrbbot mrbbot deleted the bcoll/log-warnings-to-stderr branch November 28, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants