Skip to content

Conversation

@dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Jul 17, 2025

Fixed https://jira.cfdata.org/browse/DEVX-2087
Fixes #8063


@changeset-bot
Copy link

changeset-bot bot commented Jul 17, 2025

🦋 Changeset detected

Latest commit: b3ccc35

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
wrangler Patch
miniflare Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch
@cloudflare/pages-shared Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 17, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10004

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10004

miniflare

npm i https://pkg.pr.new/miniflare@10004

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10004

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10004

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10004

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10004

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10004

wrangler

npm i https://pkg.pr.new/wrangler@10004

commit: b3ccc35

@dario-piotrowicz dario-piotrowicz changed the title fix wrangler dev logs being logged on the incorrect level some times @dario-piotrowicz fix wrangler dev logs being logged on the incorrect level some times Jul 17, 2025
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch 3 times, most recently from 36f2c53 to 376b15d Compare July 17, 2025 22:37
@dario-piotrowicz dario-piotrowicz changed the title fix wrangler dev logs being logged on the incorrect level some times fix wrangler dev logs being logged on the incorrect level in some cases Jul 17, 2025
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch 7 times, most recently from 73df5c3 to ba19731 Compare July 18, 2025 12:32
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch 2 times, most recently from 80669b8 to fdf3ecb Compare July 18, 2025 14:33
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review July 18, 2025 16:48
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner July 18, 2025 16:48
@dario-piotrowicz
Copy link
Member Author

@danlapid I've added you as a reviewer just in case you were interested since you added the structured logging feature to workerd 🙌 🫶

@danlapid
Copy link
Contributor

@danlapid I've added you as a reviewer just in case you were interested since you added the structured logging feature to workerd 🙌 🫶

🥳 🥳 🥳
Did everything work well for you with it? Any issues?

@dario-piotrowicz
Copy link
Member Author

@danlapid I've added you as a reviewer just in case you were interested since you added the structured logging feature to workerd 🙌 🫶

🥳 🥳 🥳 Did everything work well for you with it? Any issues?

Hey @danlapid 🙂

All very good generally thanks 🫶

One thing that I thought could be a bit problematic but I am getting worried that it could be quite problematic is this regex: https://github.com/cloudflare/workers-sdk/blob/fdf3ecbf8b07c5193a0d5215e4c193059719182a/packages/wrangler/src/dev/miniflare.ts#L1192C3-L1192C74

I can be quite brittle.... I will try to make it more robust (I need to add some more testing around this 🤔)

But however much I can improve it, I feel like it can always be a bit brittle to some extent 🤔 (since user logs can literally have anything in them...)
I was considering.... do you think we could also add a workerd option to have the message in the structured logs be in base64 or something to that extent? (so that we could extract the message and convert it back to text format on our end) that would make this sort of operation very robust I think 🤔

@danlapid
Copy link
Contributor

danlapid commented Jul 19, 2025

@danlapid I've added you as a reviewer just in case you were interested since you added the structured logging feature to workerd 🙌 🫶

🥳 🥳 🥳 Did everything work well for you with it? Any issues?

Hey @danlapid 🙂

All very good generally thanks 🫶

One thing that I thought could be a bit problematic but I am getting worried that it could be quite problematic is this regex: https://github.com/cloudflare/workers-sdk/blob/fdf3ecbf8b07c5193a0d5215e4c193059719182a/packages/wrangler/src/dev/miniflare.ts#L1192C3-L1192C74

I can be quite brittle.... I will try to make it more robust (I need to add some more testing around this 🤔)

But however much I can improve it, I feel like it can always be a bit brittle to some extent 🤔 (since user logs can literally have anything in them...) I was considering.... do you think we could also add a workerd option to have the message in the structured logs be in base64 or something to that extent? (so that we could extract the message and convert it back to text format on our end) that would make this sort of operation very robust I think 🤔

Why not just use a json parser?

@dario-piotrowicz
Copy link
Member Author

Why not just use a json parser?

mh... yeah that's a good point! Thanks I'll try that 🙂👍

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch from fdf3ecb to f478ebd Compare July 21, 2025 08:40
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch from b23b844 to 5eb20bc Compare July 21, 2025 10:28
@dario-piotrowicz
Copy link
Member Author

Why not just split by newlines though? Are you worried that the logs can have newlines? I am pretty sure these should be correctly escaped by our json encoder.

Nice! I actually didn't know that they were consistently divided by newlines 😃

Thanks for the suggestion, I've applied that and it seems to work very nicely 🫶

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch 3 times, most recently from 5d14fec to 98b0c9e Compare July 22, 2025 01:21
QUEUE: 11,
ANALYTICS_ENGINE: 12,
HYPERDRIVE: 13,
DURABLE_OBJECT_CLASS: 14,
Copy link
Contributor

Choose a reason for hiding this comment

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

this is all auto-generated right? but do you why the DO stuff has been added in? is this just because we haven't updated this file recently since the facets stuff was added to the runtime? i wonder if this is something we should automate

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah this was automatically generated via

"capnp:workerd": "node scripts/build-capnp.mjs",

honestly I haven't really looked much at the changes in the file 😕 (as it just works and doesn't seem to break anything)

I guess it can be periodically automated, but I think that there's no much benefit in it since the file only needs to update when miniflare needs to pass new/different capnp configs, and that updating it only when necessary makes sense to me 🤔
(In other words, I think that the file getting updated when Miniflare doesn't use the new options is not going to have any effect anyways)

I'd be keen to hear what @penalosa thinks of this 🙂

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Jul 22, 2025
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch 2 times, most recently from 812faac to f6e1b92 Compare July 25, 2025 22:56
@dario-piotrowicz dario-piotrowicz marked this pull request as draft July 28, 2025 08:40
@dario-piotrowicz
Copy link
Member Author

dario-piotrowicz commented Jul 28, 2025

PR converted to draft as I think it now needs to wait for cloudflare/workerd#4620 to be merged (released and bumped in wrangler).

Also a test for top level errors (like the one I mentioned above) that would get logged onto stderr, should be added.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch from 384679f to c6e5510 Compare July 30, 2025 16:02
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch from 0f7df5e to d25e783 Compare July 30, 2025 19:44
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review July 30, 2025 21:55
@dario-piotrowicz
Copy link
Member Author

I've added the skip-v3-pr label just to make the CI happy, I do already have the v3 PR open, once this PR is merged I will fix the v3 PR

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2087/fix-warns-as-errors branch from 2dc6b72 to b3ccc35 Compare July 31, 2025 14:06
@dario-piotrowicz dario-piotrowicz merged commit b4d1373 into main Jul 31, 2025
45 of 49 checks passed
@dario-piotrowicz dario-piotrowicz deleted the dario/DEVX-2087/fix-warns-as-errors branch July 31, 2025 15:50
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Jul 31, 2025
dario-piotrowicz added a commit that referenced this pull request Jul 31, 2025
…rect level in some cases (#10015)

* [miniflare] add `structuredWorkerdLogs` option

* fix `wrangler dev` logs being logged on the incorrect level in some cases

* update lock file

* adapt tests for v3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

🐛 BUG: wrangler prints ERROR for console.warn()

3 participants