Closed disrae closed 10 months ago
Hello @disrae. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro
will be closed if they have no activity within 3 days.
This seems like an important issue. However, we can't investigate without a simple project to debug and try fixes on.
Okay I will do, however the repro will have to be deployed on vercel for it to cause the issue.
@disrae could you try with npm install @astrojs/vercel@experimental--9624
?
Hmm, it works in the new project, let me try upgrading astro from 4.0.6 to 4.1 or to your version. Reproduction repo site, which works, not much to see here
Could there be some kind of build cache on Vercel that I need to clear?
This seems like the reproduction is a production deploy?
Also, the issue happens on vercel in preview deploys.
Yeah, I noticed from the URL - it isn't the same issue I ran into earlier.
Your old project (linked in the issue description) responds with a 500. What do the logs say?
one second... reproducing....
Okay, upon re-reproducing in the main project, the patch version for the vercel adapter incremented by 2, and the issue seems to be gone!
Latest Vercel adapter package seems to have solved the issue.
"@astrojs/vercel": "^6.1.2"
Okay, it is not solved. The bug happens when I commit the files from the .vercel directory, without it it still works, and I'm getting the logs as well, which is the only reason I am using hybrid mode, to see which pages are missing redirects, aka 404ing.
Is the result any different when using the vercel CLI?
pnpm exec astro build
pnpm exec vercel deploy --prebuilt --prod
Sorry bogged down, but trying to get to that.
vercel deploy
gave me some trouble, said I didn't have a project by the name, despite being in the correct account and such, then it seemed to not automatically know it was an Astro project and the defaults it was presenting didn't seem right, so I backed out.
I did however manage to reproduce the issue by pushing the .vercel/ directory, is that directory meant to be strictly local?
2024-01-06T01:16:20.477Z undefined ERROR Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/dist/entry.mjs' imported from /var/task/___vc/__launcher/bridge-server-72TT5FOD.js
at new NodeError (node:internal/errors:406:5)
at finalizeResolution (node:internal/modules/esm/resolve:238:11)
at moduleResolve (node:internal/modules/esm/resolve:850:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:972:12)
at defaultResolve (node:internal/modules/esm/resolve:1091:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:228:38)
at ModuleLoader.import (node:internal/modules/esm/loader:315:34)
at importModuleDynamically (node:internal/modules/cjs/loader:1164:37) {
url: 'file:///var/task/dist/entry.mjs',
code: 'ERR_MODULE_NOT_FOUND'
}
INIT_REPORT Init Duration: 191.03 ms Phase: init Status: error Error Type: Runtime.ExitError
2024-01-06T01:16:20.703Z undefined ERROR Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/dist/entry.mjs' imported from /var/task/___vc/__launcher/bridge-server-72TT5FOD.js
at new NodeError (node:internal/errors:406:5)
at finalizeResolution (node:internal/modules/esm/resolve:238:11)
at moduleResolve (node:internal/modules/esm/resolve:850:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:972:12)
at defaultResolve (node:internal/modules/esm/resolve:1091:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:228:38)
at ModuleLoader.import (node:internal/modules/esm/loader:315:34)
at importModuleDynamically (node:internal/modules/cjs/loader:1164:37) {
url: 'file:///var/task/dist/entry.mjs',
code: 'ERR_MODULE_NOT_FOUND'
}
INIT_REPORT Init Duration: 214.27 ms Phase: invoke Status: error Error Type: Runtime.ExitError
Error: Runtime exited with error: exit status 1
From the error message, I can tell that vercel's platform is looking at wrong place. No astro code has run before that error occurs.
It might be because install/build/start commands are set to a wrong preset in the project config. Can you try again by deploying to a new project?
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using hybrid rendering, if I push my .vercel/ directory to the repo the 404 page function does not work. 404 with: ✅ Static rendering ✅ Hybrid localhost with 404 as function or static ❌ Hybrid on Vercel with 404 as function or static returns 500 error
500 error:
What's the expected result?
Expected 404 serverless function to return the 404 page. https://docs.astro.build/en/guides/server-side-rendering/#add-an-adapter https://docs.astro.build/en/guides/server-side-rendering/#opting-out-of-pre-rendering-in-hybrid-mode
Link to Minimal Reproducible Example
https://goose-website-cbarwkiun-goose-insurance-1c431eed.vercel.app/en-us/should-go-to-404
Participation