Skip to content

Conversation

@penalosa
Copy link
Contributor

@penalosa penalosa commented Sep 23, 2025

Fixes DEVX-2213

Previously, the formatMessage utility was heavily used across the Wrangler codebase to nicely format ParseError-style error messages. This led to nice display, but had two problems:

  • It was used via logger.log(formatMessage(...)), which meant that a large chunk of Wrangler's error messages were shoing up in stdout rather than stderr
  • It needed to be used intentionally, which meant that in various places we logged out a potentional ParseError without applying the formatting (leading to hard to understand stack traces being shown to users when e.g. a preview session failed)

Now, logger.error() will automatically apply formatMessage() when the first argument is a ParseError


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal refactor
  • Wrangler V3 Backport
@penalosa penalosa requested review from a team as code owners September 23, 2025 14:06
@changeset-bot
Copy link

changeset-bot bot commented Sep 23, 2025

🦋 Changeset detected

Latest commit: 46d8a85

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

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers 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

*/
export function isAbortError(err: unknown) {
const legacyAbortErroCheck = (err as { code: string }).code !== "ABORT_ERR";
const legacyAbortErroCheck = (err as { code: string }).code == "ABORT_ERR";
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 think this is a bug. As such, I've changed this equality check, and inverted the callsites of isAbortError(), which seems to make more sense to me.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 23, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 46d8a85

@github-actions
Copy link
Contributor

Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the v3-maintenance branch with your changes. Thank you for helping us keep Wrangler v3 supported!

Depending on your changes, running git rebase --onto v3-maintenance main penalosa/improve-error-logging might be a good starting point.

Notes:

  • your PR branch should be named v3-backport-10734
  • add the skip-v3-pr label to the current PR to stop this workflow from failing
@penalosa penalosa added the skip-v3-pr Skip validation of presence of a v3 backport PR label Sep 26, 2025
@penalosa penalosa force-pushed the penalosa/improve-error-logging branch from e9d1bee to c36561c Compare September 26, 2025 12:14
@penalosa penalosa mentioned this pull request Sep 26, 2025
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Sep 29, 2025
@penalosa penalosa merged commit 8d7f32e into main Sep 30, 2025
38 of 42 checks passed
@penalosa penalosa deleted the penalosa/improve-error-logging branch September 30, 2025 12:42
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Sep 30, 2025
edmundhung pushed a commit that referenced this pull request Oct 3, 2025
* Improve error logging * Create spotty-knives-roll.md * fix lint * fix tests * fix tests * drop sentry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-v3-pr Skip validation of presence of a v3 backport PR

2 participants