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

assets: Vercel's serverless function crashes #6470

Closed
1 task
vinhphm opened this issue Mar 9, 2023 · 4 comments · Fixed by #6488
Closed
1 task

assets: Vercel's serverless function crashes #6470

vinhphm opened this issue Mar 9, 2023 · 4 comments · Fixed by #6488
Assignees
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) feat: assets Related to the Assets feature (scope)

Comments

@vinhphm
Copy link

vinhphm commented Mar 9, 2023

What version of astro are you using?

2.1.2

Are you using an SSR adapter? If so, which one?

Vercel

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

After migrated to assets folder and ran dev in localhost, everything went well.
Then I deployed to Vercel, with the latest integration package (3.2.0), the build succeeded but then when I accessed the site, the serverless function failed with error as below in the logs:

Cannot find module 'image-size'
Require stack:
- /var/task/dist/chunks/astro.0e1c7d6a.mjs
Did you forget to add it to "dependencies" in `package.json`?
RequestId: 2feb46af-d7d4-4854-9e51-0c4cd3b61b89 Error: Runtime exited with error: exit status 1
Runtime.ExitError

Here is the link to the preview deployment: https://vinh-dev-git-assets-vinhphm.vercel.app/

Link to Minimal Reproducible Example

None. I don't think I can reproduce it in Stackblitz since it related to Vercel

Participation

  • I am willing to submit a pull request for this issue.
@vinhphm vinhphm changed the title assets: Vercel's serverless function fails assets: Vercel's serverless function crashes Mar 9, 2023
@ezracelli
Copy link

This is also an issue locally when using PnP, even with the experimental setting turned off.

Running astro build:

Error: Your application tried to access image-size, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: image-size
Required by: /xxx/public/chunks/

Require stack:
- /xxx/public/chunks/astro.a1d66767.mjs
    at require$$0.Module._resolveFilename (/xxx/.pnp.cjs:12000:13)
    at require$$0.Module._load (/xxx/.pnp.cjs:11851:42)
    at Module.require (node:internal/modules/cjs/loader:1113:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at file:///xxx/public/chunks/astro.a1d66767.mjs:2065:1
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

@Princesseuh
Copy link
Member

Hmm, seems like one of our dependency is getting externalized by mistake, will take a look thank you!

Sorry for the inconvenience

@Princesseuh Princesseuh self-assigned this Mar 9, 2023
@Princesseuh Princesseuh linked a pull request Mar 9, 2023 that will close this issue
@Princesseuh Princesseuh added feat: assets Related to the Assets feature (scope) - P4: important Violate documented behavior or significantly impacts performance (priority) - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) and removed - P4: important Violate documented behavior or significantly impacts performance (priority) labels Mar 9, 2023
@vinhphm
Copy link
Author

vinhphm commented Mar 14, 2023

@Princesseuh I just updated to version 2.1.3, and it seems to have a new issue in the serverless function. Here is what on the log:

Invoke Error 	{"errorType":"Error","errorMessage":"socket hang up","code":"ECONNRESET","stack":["Error: socket hang up","    at connResetException (node:internal/errors:718:14)","    at Socket.socketOnEnd (node:_http_client:520:23)","    at Socket.emit (node:events:525:35)","    at endReadableNT (node:internal/streams/readable:1359:12)","    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"]}

@JayBox325
Copy link

I'm getting this error too. I've stripped out everything (it did have Sanity integrated) but it's now just two blank HTML templates and I'm still getting this with my config being:

import { defineConfig } from 'astro/config';
import vercelServerless from '@astrojs/vercel/serverless';

export default defineConfig({
  // Vercel
  output: "server",
  adapter: vercelServerless()
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) feat: assets Related to the Assets feature (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants