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

fix: runBuild should exit with 1 on unexpected errors (when watch mode is disabled) #754

Merged

Conversation

juanferreras
Copy link
Contributor

@juanferreras juanferreras commented Apr 22, 2024

(Maybe) partially addresses: #740. (EDIT: OP seems to have a different issue, the build does go through without errors even though the worker is somehow malformed).

I've encountered a similar issue on my own, we had an import of a file with multiple locale-specific characters, and it was causing the .vercel/output/functions/<page-name>.func/index.js to contain a blurb like

Ş:"Scedil",ß:"szlig",𝔱:"tfr",𝓉:"tscr",𝕥:"topf",𝒯:"Tscr",𝔗:"Tfr",𝕋:"Topf",ť:"tcaron",Ť:"Tcaron",ţ:"tcedil",Ţ:"Tcedil","™":"trade",ŧ:"tstrok",Ŧ:"Tstrok",𝓊:"uscr",𝕦:"uopf",𝔲:"ufr",𝕌:"Uopf",𝔘:"Ufr",𝒰:"Uscr",ú:"uacute",Ú:"Uacute",ù:"ugrave",Ù:"Ugrave",ŭ:"ubreve",Ŭ:"Ubreve",û:"ucirc",Û:"Ucirc",ů:"uring",Ů:"Uring",ü:"uuml",Ü:"Uuml",ű:"udblac",Ű:"Udblac",ũ:"utilde",Ũ:"Utilde",ų:"uogon",Ų:"Uogon",ū:"umacr",Ū:"Umacr",𝔳:"vfr",𝕧:"vopf",𝓋:"vscr",𝔙:"Vfr",𝕍:"Vopf",𝒱:"Vscr",𝕨:"wopf",𝓌:"wscr"

which caused the build logs to output

▲  Collected static files (public/, static/, .next/static): 59.326ms
▲  Build Completed in .vercel/output [4m]
⚡️ Completed `pnpm dlx vercel build`.
⚡️ Unexpected error: Unexpected character '�' (8036:87743)

I wasn't able to come up with a simple repro on this specific issue (and it looks more like something our project was doing wrong), but it's fairly simple to test that if acorn's parse() throws inside getFunctionIdentifiers(), the deploy fails and the exit code is 0 (which means CI or a command that does && pnpm run:deploy would carry on with a broken build).
CleanShot 2024-04-22 at 09 16 05@2x

In our case, it was creating the same defect as OP has on #740, a deployment successfully goes out but all paths return 404 (even homepage) as something goes wrong building the worker's code.

I'm assuming there might be N different reasons why a build can fail at this stage, but if they're all going through the unexpected error path, I'd assume we'll always want to signal exit 1 to prevent deployments to continue broken.

Copy link

changeset-bot bot commented Apr 22, 2024

🦋 Changeset detected

Latest commit: 0c4657a

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

This PR includes changesets to release 2 packages
Name Type
@cloudflare/next-on-pages Patch
eslint-plugin-next-on-pages 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

Copy link
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks a bunch @juanferreras 😄

.changeset/loud-owls-remember.md Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Apr 22, 2024

🧪 Prereleases are available for testing 🧪

@cloudflare/next-on-pages

You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/8790732945/npm-package-next-on-pages-754

@cloudflare/eslint-plugin-next-on-pages

You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/8790732945/npm-package-eslint-plugin-next-on-pages-754

@dario-piotrowicz dario-piotrowicz merged commit 446e9af into cloudflare:main Apr 22, 2024
8 checks passed
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.

2 participants