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: store temporary files in .wrangler #4127

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Oct 6, 2023

Fixes #4052

What this PR solves / how to test:

Previously, Wrangler used the OS's default temporary directory. On Windows, this is usually on the C: drive. If your source code was on a different drive, esbuild would generate invalid source maps (source paths relative to the cwd were used verbatim in the output, rather than being relative to sources root and the source map location), breaking breakpoint debugging in VSCode. This change ensures intermediate files are always written to the same drive as sources. It also ensures unused bundle outputs are cleaned up between wrangler pages dev reloads, and the same file path is used for writing functions routes.

To test, create a new Wrangler project using Windows on a non-C: drive. Try to set a breakpoint using VSCode. You should be able to hit it. 🎉

Associated docs issue(s)/PR(s):

N/A

Author has included the following, where applicable:

  • Tests (not sure how we can guarantee the tests run on a different drive 🤔)
  • Changeset (Changeset guidelines)

Reviewer is to perform the following, as applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

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 review from a team as code owners October 6, 2023 11:22
@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2023

🦋 Changeset detected

Latest commit: 90e3a12

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 changed the title fix: store temporary files in .wrangler [wrangler] fix: store temporary files in .wrangler Oct 6, 2023
Previously, Wrangler used the OS's default temporary directory. On
Windows, this is usually on the `C:` drive. If your source code was
on a different drive, `esbuild` would generate invalid source maps
(source paths relative to the cwd were used verbatim in the output,
rather than being relative to sources root and the source map
location), breaking breakpoint debugging in VSCode. This change
ensures intermediate files are always written to the same drive as
sources. It also ensures unused bundle outputs are cleaned up between
`wrangler pages dev` reloads, and the same file path is used for
writing functions routes.

Closes #4052
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Merging #4127 (90e3a12) into main (ef35c3b) will increase coverage by 0.08%.
Report is 1 commits behind head on main.
The diff coverage is 94.20%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4127      +/-   ##
==========================================
+ Coverage   75.31%   75.40%   +0.08%     
==========================================
  Files         223      223              
  Lines       12191    12227      +36     
  Branches     3151     3160       +9     
==========================================
+ Hits         9182     9220      +38     
+ Misses       3009     3007       -2     
Files Coverage Δ
packages/wrangler/src/api/pages/deploy.tsx 86.15% <100.00%> (ø)
packages/wrangler/src/deploy/deploy.ts 87.93% <100.00%> (+0.03%) ⬆️
packages/wrangler/src/deploy/index.ts 95.23% <100.00%> (+0.11%) ⬆️
packages/wrangler/src/dev.tsx 83.67% <100.00%> (+0.13%) ⬆️
packages/wrangler/src/dev/start-server.ts 79.09% <100.00%> (-0.19%) ⬇️
packages/wrangler/src/pages/buildFunctions.ts 90.00% <100.00%> (ø)
...ckages/wrangler/src/pages/functions/buildPlugin.ts 22.58% <100.00%> (+2.58%) ⬆️
...ckages/wrangler/src/pages/functions/buildWorker.ts 71.87% <100.00%> (ø)
packages/wrangler/src/pages/utils.ts 100.00% <100.00%> (ø)
packages/wrangler/src/paths.ts 100.00% <100.00%> (ø)
... and 2 more

... and 3 files with indirect coverage changes

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 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/6431012321/npm-package-wrangler-4127

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6431012321/npm-package-wrangler-4127 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6431012321/npm-package-cloudflare-pages-shared-4127

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


wrangler@3.11.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare 3.20231002.1 3.20231002.1
workerd 1.20231002.0 1.20231002.0
workerd --version 1.20231002.0 2023-10-02

|

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

Copy link
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

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

Tentatively looks good, but I'd love to test it on Windows first next week

@JustinGrote
Copy link

JustinGrote commented Oct 13, 2023

@mrbbot I can confirm this fixed it for me, I had my repository on my Windows DevDrive (D:) and breakpoints would not hit, even if I did it via my mounted C: symlink ($HOME/Projects).

After installing this wrangler, seems to be fine.
image

Thank you! This was driving me crazy that I had done something wrong.

@mrbbot mrbbot merged commit 3d55f96 into main Oct 26, 2023
20 checks passed
@mrbbot mrbbot deleted the bcoll/dot-wrangler-tmp-dir branch October 26, 2023 15:50
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.

🐛 BUG: VSCode breakpoint debugging fails to load sources on non C:/ drives
3 participants