We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 following code...
try { const mod = await server.ssrLoadModule('/non-existent'); do_something_with(mod); } catch (e) { // error is handled, no warning should appear }
...results in this:
UnhandledPromiseRejectionWarning: Error: failed to load module for ssr: /non-existent
package.json
{ "scripts": { "start": "node server.js" }, "devDependencies": { "vite": "^2.0.1" }, "type": "module" }
server.js
import vite from 'vite'; async function main() { const server = await vite.createServer(); try { await server.ssrLoadModule('/non-existent'); } catch (e) { console.error('handled', e); } } main();
Expected result: it prints 'handled' along with the error. Actual result: it prints 'handled' alongside the unhandled promise rejection warning.
The culprit is this line...
vite/packages/vite/src/node/ssr/ssrModuleLoader.ts
Line 49 in 8ed67cf
...which needs a catch:
catch
-modulePromise.then(() => pendingModules.delete(url)) +modulePromise.catch(() => {}).then(() => pendingModules.delete(url))
vite
The text was updated successfully, but these errors were encountered:
fix: handle ssrLoadModule failures. closes vitejs#2252
faea2c4
fix(ssr): handle ssrLoadModule failures in post pending (#2253)
ea323cc
fix #2252
Successfully merging a pull request may close this issue.
Describe the bug
The following code...
...results in this:
Reproduction
package.json
server.js
Expected result: it prints 'handled' along with the error. Actual result: it prints 'handled' alongside the unhandled promise rejection warning.
The culprit is this line...
vite/packages/vite/src/node/ssr/ssrModuleLoader.ts
Line 49 in 8ed67cf
...which needs a
catch
:System Info
vite
version: 2.0.3The text was updated successfully, but these errors were encountered: