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

[wrangler] fix: apply source mapping to deployment validation errors #4600

Merged
merged 6 commits into from
Jan 2, 2024

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Dec 13, 2023

Fixes #2741.

What this PR solves / how to test:

Previously if a Worker failed validation during wrangler deploy, the displayed error would reference locations in built JavaScript files. This made it more difficult to debug validation errors. This change ensures these errors are now source mapped, referencing locations in source files instead. To test this, try to deploy a TypeScript worker referencing a non-existent variable in the global scope. The validation error should include the location in the TypeScript file.

Author has addressed the following:

  • Tests
    • Included
    • Not necessary because:
  • Changeset (Changeset guidelines)
    • Included
    • Not necessary because:
  • Associated docs
    • Issue(s)/PR(s):
    • Not necessary because: change to error messaging

Note for PR author:

We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label highlight pr review so future reviewers can take inspiration and learn from it.

@mrbbot mrbbot requested a review from a team as a code owner December 13, 2023 11:36
Copy link

changeset-bot bot commented Dec 13, 2023

🦋 Changeset detected

Latest commit: 4ad7a7a

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

This PR includes changesets to release 1 package
Name Type
wrangler 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

@mrbbot mrbbot force-pushed the bcoll/source-mapped-validation-errors branch from 6d9afd3 to 86bc516 Compare December 13, 2023 11:38
Copy link
Contributor

github-actions bot commented Dec 13, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387305238/npm-package-wrangler-4600

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7387305238/npm-package-wrangler-4600

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387305238/npm-package-wrangler-4600 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387305238/npm-package-miniflare-4600
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387305238/npm-package-cloudflare-pages-shared-4600
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387305238/npm-package-create-cloudflare-4600 --no-auto-update

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.22.1 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20231030.4
workerd 1.20231030.0 1.20231030.0
workerd --version 1.20231030.0 2023-10-30

|

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@mrbbot mrbbot force-pushed the bcoll/source-mapped-strings branch 3 times, most recently from 0fd9b75 to fac2f99 Compare December 14, 2023 13:52
Base automatically changed from bcoll/source-mapped-strings to main December 15, 2023 13:44
@mrbbot mrbbot force-pushed the bcoll/source-mapped-validation-errors branch from 86bc516 to 787cbfa Compare December 18, 2023 11:13
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (912bfeb) 75.46% compared to head (4ad7a7a) 75.55%.
Report is 30 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4600      +/-   ##
==========================================
+ Coverage   75.46%   75.55%   +0.08%     
==========================================
  Files         242      242              
  Lines       12957    13074     +117     
  Branches     3331     3367      +36     
==========================================
+ Hits         9778     9878     +100     
- Misses       3179     3196      +17     
Files Coverage Δ
packages/wrangler/src/deploy/deploy.ts 90.33% <100.00%> (+0.33%) ⬆️
packages/wrangler/src/sourcemap.ts 66.91% <94.59%> (+43.61%) ⬆️

... and 16 files with indirect coverage changes

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

I know it is quite awkward but we might need to construct some actual source and compiled files, with source maps that can act as additional modules, etc so that we can cover the missing code-paths in tests.

packages/wrangler/src/sourcemap.ts Outdated Show resolved Hide resolved
packages/wrangler/src/sourcemap.ts Outdated Show resolved Hide resolved
@petebacondarwin petebacondarwin added the error-messaging Improving user facing error messages label Dec 22, 2023
mrbbot added 3 commits January 2, 2024 13:48
Rename `RetrieveSourceMap` to `RetrieveSourceMapFunction`
Add comment highlighting why `retrieveSourceMapOverride` module level
Add tests for different types of modules/source maps
@mrbbot
Copy link
Contributor Author

mrbbot commented Jan 2, 2024

I've added tests for the missing code paths in 6653a30 🙂

@mrbbot mrbbot requested a review from petebacondarwin January 2, 2024 14:27
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Magic!

packages/wrangler/src/__tests__/deploy.test.ts Outdated Show resolved Hide resolved
@mrbbot mrbbot merged commit 4233e51 into main Jan 2, 2024
17 checks passed
@mrbbot mrbbot deleted the bcoll/source-mapped-validation-errors branch January 2, 2024 15:33
@workers-devprod workers-devprod mentioned this pull request Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messaging Improving user facing error messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: "A request to the CloudFlare API... failed" errors are non-obvious and confusing.
3 participants