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

Incorrect SSR error when importing package with incorrect import paths #12322

Closed
7 tasks done
bluwy opened this issue Mar 7, 2023 · 2 comments · Fixed by #12324
Closed
7 tasks done

Incorrect SSR error when importing package with incorrect import paths #12322

bluwy opened this issue Mar 7, 2023 · 2 comments · Fixed by #12324
Labels
feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@bluwy
Copy link
Member

bluwy commented Mar 7, 2023

Describe the bug

When importing a package in SSR that would've error-ed in node too, Vite swallows the node error, and shims the module as undefined instead, causing hard-to-debug Cannot read properties of undefined errors.

It would be good to surface the errors directly. It seems to be swallowed at

(Discovered through withastro/astro#6403)

Reproduction

https://stackblitz.com/edit/bluwy-create-vite-extra-56u3yb?file=src%2Fmain.js,test.js

Steps to reproduce

Run node test.js. See main.js to see the file that gets loaded with comments of why it's erroring.

System Info

stackblitz

Used Package Manager

pnpm

Logs

Click to expand!
Error: Cannot read properties of undefined (reading 'default')
    at eval (/src/main.js:7:35)
    at async ESMLoader.import (https://bluwycreateviteextra56u3yb-mer3.w-credentialless.staticblitz.com/blitz.50571018ddcbc3a25df8994336c28d766f1073a1.js:6:1209137)
    at async i.loadESM (https://bluwycreateviteextra56u3yb-mer3.w-credentialless.staticblitz.com/blitz.50571018ddcbc3a25df8994336c28d766f1073a1.js:6:246622)
    at async handleMainPromise (https://bluwycreateviteextra56u3yb-mer3.w-credentialless.staticblitz.com/blitz.50571018ddcbc3a25df8994336c28d766f1073a1.js:6:989144)

Validations

@bluwy bluwy added p3-minor-bug An edge case that only affects very specific usage (priority) feat: ssr labels Mar 7, 2023
@stackblitz
Copy link

stackblitz bot commented Mar 7, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@bluwy
Copy link
Member Author

bluwy commented Mar 10, 2023

Update: I realized now why the local package repro had a better error message. Because the types.js file doesn't exist, Vite was able to provide a better error message. But for astro-integration-lottie, types.js exist and Vite can resolve it, so no error message.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant