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

The Astro got crashed when use the Container API and deploy on vercel with server mode #11181

Closed
1 task
syhily opened this issue Jun 4, 2024 · 4 comments · Fixed by #11251
Closed
1 task
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: container Related to the container API (scope)

Comments

@syhily
Copy link
Contributor

syhily commented Jun 4, 2024

Astro Info

Astro                    v4.9.2
Node                     v22.2.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/vercel/serverless
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When the Astro project use the Container API internally. The build on vercel platform works as expected but soon crashed when access the production link. The error log is attached below:

u. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
at requireWithFriendlyError (/var/task/vercel/path0/node_modules/rollup/dist/native.js:59:9)
at Object.<anonymous> (/var/task/vercel/path0/node_modules/rollup/dist/native.js:68:76)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at /opt/rust/nodejs.js:1:11497
at Function.Lt (/opt/rust/nodejs.js:1:11867)
at G.e.<computed>.z._load (/opt/rust/nodejs.js:1:11467)
at cjsLoader (node:internal/modules/esm/translators:348:17) {
[cause]: Error: Cannot find module '@rollup/rollup-linux-x64-gnu'
Require stack:
- /var/task/vercel/path0/node_modules/rollup/dist/native.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at /opt/rust/nodejs.js:1:11497
at Function.Lt (/opt/rust/nodejs.js:1:11867)
at G.e.<computed>.z._load (/opt/rust/nodejs.js:1:11467)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at requireWithFriendlyError (/var/task/vercel/path0/node_modules/rollup/dist/native.js:41:10)
at Object.<anonymous> (/var/task/vercel/path0/node_modules/rollup/dist/native.js:68:76)
at Module._compile (node:internal/modules/cjs/loader:1358:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/task/vercel/path0/node_modules/rollup/dist/native.js' ]
}
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
INIT_REPORT Init Duration: 812.29 ms	Phase: init	Status: error	Error Type: Runtime.ExitError
Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
at requireWithFriendlyError (/var/task/vercel/path0/node_modules/rollup/dist/native.js:59:9)
at Object.<anonymous> (/var/task/vercel/path0/node_modules/rollup/dist/native.js:68:76)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at /opt/rust/nodejs.js:1:11497
at Function.Lt (/opt/rust/nodejs.js:1:11867)
at G.e.<computed>.z._load (/opt/rust/nodejs.js:1:11467)
at cjsLoader (node:internal/modules/esm/translators:348:17) {
[cause]: Error: Cannot find module '@rollup/rollup-linux-x64-gnu'
Require stack:
- /var/task/vercel/path0/node_modules/rollup/dist/native.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at /opt/rust/nodejs.js:1:11497
at Function.Lt (/opt/rust/nodejs.js:1:11867)
at G.e.<computed>.z._load (/opt/rust/nodejs.js:1:11467)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at requireWithFriendlyError (/var/task/vercel/path0/node_modules/rollup/dist/native.js:41:10)
at Object.<anonymous> (/var/task/vercel/path0/node_modules/rollup/dist/native.js:68:76)
at Module._compile (node:internal/modules/cjs/loader:1358:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/task/vercel/path0/node_modules/rollup/dist/native.js' ]
}
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
INIT_REPORT Init Duration: 1912.29 ms	Phase: invoke	Status: error	Error Type: Runtime.ExitError

Related issue: #11128

What's the expected result?

It shouldn't crash.

Link to Minimal Reproducible Example

https://github.com/syhily/container-repro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jun 4, 2024
@matthewp
Copy link
Contributor

matthewp commented Jun 5, 2024

Tomorrow we will be releasing 4.10 which will allow you to do it this way: https://github.com/withastro/astro/blob/4ad1ce24e1306a8330fb6f77c8b13394704e1fef/.changeset/fair-singers-reflect.md

Would be good to try it out when that is out.

@syhily
Copy link
Contributor Author

syhily commented Jun 6, 2024

@matthewp Thanks. After trying to migrate to the new Render, I still met the same issue. And the loadRenderers can't be imported by vite. I don't know why.

. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
at requireWithFriendlyError (/var/task/vercel/path0/node_modules/rollup/dist/native.js:59:9)
at Object.<anonymous> (/var/task/vercel/path0/node_modules/rollup/dist/native.js:68:76)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at /opt/rust/nodejs.js:1:11497
at Function.Lt (/opt/rust/nodejs.js:1:11867)
at G.e.<computed>.z._load (/opt/rust/nodejs.js:1:11467)
at cjsLoader (node:internal/modules/esm/translators:348:17) {
[cause]: Error: Cannot find module '@rollup/rollup-linux-x64-gnu'
Require stack:
- /var/task/vercel/path0/node_modules/rollup/dist/native.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at /opt/rust/nodejs.js:1:11497
at Function.Lt (/opt/rust/nodejs.js:1:11867)
at G.e.<computed>.z._load (/opt/rust/nodejs.js:1:11467)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at requireWithFriendlyError (/var/task/vercel/path0/node_modules/rollup/dist/native.js:41:10)
at Object.<anonymous> (/var/task/vercel/path0/node_modules/rollup/dist/native.js:68:76)
at Module._compile (node:internal/modules/cjs/loader:1358:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/task/vercel/path0/node_modules/rollup/dist/native.js' ]
}
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
INIT_REPORT Init Duration: 1118.69 ms	Phase: init	Status: error	Error Type: Runtime.ExitError
Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
at requireWithFriendlyError (/var/task/vercel/path0/node_modules/rollup/dist/native.js:59:9)
at Object.<anonymous> (/var/task/vercel/path0/node_modules/rollup/dist/native.js:68:76)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at /opt/rust/nodejs.js:1:11497
at Function.Lt (/opt/rust/nodejs.js:1:11867)
at G.e.<computed>.z._load (/opt/rust/nodejs.js:1:11467)
at cjsLoader (node:internal/modules/esm/translators:348:17) {
[cause]: Error: Cannot find module '@rollup/rollup-linux-x64-gnu'
Require stack:
- /var/task/vercel/path0/node_modules/rollup/dist/native.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at /opt/rust/nodejs.js:1:11497
at Function.Lt (/opt/rust/nodejs.js:1:11867)
at G.e.<computed>.z._load (/opt/rust/nodejs.js:1:11467)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at requireWithFriendlyError (/var/task/vercel/path0/node_modules/rollup/dist/native.js:41:10)
at Object.<anonymous> (/var/task/vercel/path0/node_modules/rollup/dist/native.js:68:76)
at Module._compile (node:internal/modules/cjs/loader:1358:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/task/vercel/path0/node_modules/rollup/dist/native.js' ]
}
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
INIT_REPORT Init Duration: 1976.33 ms	Phase: invoke	Status: error	Error Type: Runtime.ExitError

@matthewp matthewp added - P4: important Violate documented behavior or significantly impacts performance (priority) feat: container Related to the container API (scope) and removed needs triage Issue needs to be triaged labels Jun 6, 2024
@matthewp
Copy link
Contributor

matthewp commented Jun 6, 2024

Ok thank you for trying. I'm wondering if it's because we try and load them dynamically. It's also possible that it's because the React integration exports them from the main integration which has dependencies on dev-mode stuff.

@YonicDev
Copy link

YonicDev commented Jun 9, 2024

I'm having no issues with Netlify with @astrojs/mdx and @astrojs/svelte here.
Although it only works if I import loadRenderers from the direct path to the virtual module file (astro/virtual-modules/container.js) which makes me think that it's not properly set up as a virtual module in Vite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: container Related to the container API (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants