Skip to content

Commit

Permalink
fix: add a warning if a user inadvertently uploads a Pages _workers.j…
Browse files Browse the repository at this point in the history
…s file as an asset

Fixes N/A
  • Loading branch information
petebacondarwin committed Sep 19, 2024
1 parent dbac042 commit 880d9e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/wrangler/src/__tests__/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4615,10 +4615,10 @@ addEventListener('fetch', event => {});`
});
await expect(runWrangler("deploy --config some/path/wrangler.toml"))
.rejects.toThrowErrorMatchingInlineSnapshot(`
[Error: Uploading a Pages _worker.js file as an asset.
[Error: Uploading a Pages _worker.js directory as an asset.
This could expose your private server-side code to the public Internet. Is this intended?
If you do not want to upload this file, either remove it or add an ".assetsignore" file, to the root of your asset directory, containing "_worker.js" to avoid uploading.
If you do want to upload this file, you can add an empty ".assetsignore" file, to the root of your asset directory, to hide this error.]
If you do not want to upload this directory, either remove it or add an ".assetsignore" file, to the root of your asset directory, containing "_worker.js" to avoid uploading.
If you do want to upload this directory, you can add an empty ".assetsignore" file, to the root of your asset directory, to hide this error.]
`);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/experimental-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ export const buildAssetManifest = async (dir: string) => {
return;
}

errorOnLegacyPagesWorkerJSAsset(relativeFilepath, !!ignoreFn);

const filepath = path.join(dir, relativeFilepath);
const filestat = await stat(filepath);

if (filestat.isSymbolicLink() || filestat.isDirectory()) {
return;
} else {
errorOnLegacyPagesWorkerJSAsset(relativeFilepath, !!ignoreFn);

if (counter >= MAX_ASSET_COUNT) {
throw new UserError(
`Maximum number of assets exceeded.\n` +
Expand Down

0 comments on commit 880d9e2

Please sign in to comment.