-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
app-vite v2 / app-webpack v4 - boot files are broken in SSR #17658
Comments
I am working the whole week on this problem now. by running const bootFiles = Promise.all([ //no top level await
[...] //not showing all imports
Promise.resolve().then(() => axios$1),
import("./assets/polyfill-BwV_9ARc.mjs"),
import("./assets/sentry-BDCNs69F.mjs")
]).then((bootFiles2) => bootFiles2.map((entry) => entry.default).filter((entry) => typeof entry === "function"));
const serverEntry = (ssrContext) => {
return new Promise(async (resolve, reject) => {
const bootFunctions = await bootFiles; // here is the await and since @quasar/app-vite-v2.0.0-beta.12: const bootFunctions = await Promise.all([ // await is now top level
[...] //not showing all imports
Promise.resolve().then(() => axios$1),
import("./assets/polyfill-BwV_9ARc.mjs"),
import("./assets/sentry-BDCNs69F.mjs")
]).then((bootFiles) => bootFiles.map((entry) => entry.default).filter((entry) => typeof entry === "function"));
const serverEntry = (ssrContext) => {
return new Promise(async (resolve, reject) => {
// directly use awaited bootFunctions from above here You can quickly test if your quasar project is running the build with this command: Reproduction steps with new blank projectSo i wondered if my project maybe have some custom issues. But no, i have node 18+ and set es2022 in quasar.conf.js as browser target, both support top level awaits. I tested if a new quasar project, created by quasar cli, will have node code 13 too.
Try Reverting commit "tweak SSR boot files management" from beta.12I also tried it the other way around in my real project. I changed back the changes made in @quasar/app-vite-v2.0.0-beta.12 for /dist/ssr/server/server-entry.mjs by doing this: const bootFunctionsFix = Promise.all([ // renamed bootFunctions, no more top level await
[...] //not showing all imports
Promise.resolve().then(() => axios$1),
import("./assets/polyfill-BwV_9ARc.mjs"),
import("./assets/sentry-BDCNs69F.mjs")
]).then((bootFiles) => bootFiles.map((entry) => entry.default).filter((entry) => typeof entry === "function"));
const serverEntry = (ssrContext) => {
return new Promise(async (resolve, reject) => {
const bootFunctions = await bootFunctionsFix; // define bootFunction here again with await I put the await back into serverEntry, away from top level and |
@LydiaSFCompetitionline I've updated the issue description with my recent findings if you want to check it. Top-level await on itself is not the issue, but some other changes resulted in a cyclic-dependency between the server-entry and boot files. That shouldn't also cause problems, but there is a NodeJS bug about this, which is linked in the PR description. Thanks for sharing your findings, they could serve as a solution. |
Fix will be available in q/app-vite v2.0.0 |
Thanks, both of you! |
Adding any boot file, even if totally empty, results in the SSR app silently exiting the app with exit code 13. Node 22 also prints a warning. The exit code 13 stands for unsettled top-level await. This is happening due to: nodejs/node#55468
This most likely started happening after moving
quasar/wrappers
to#q-app/wrappers
. A compiled boot file containsimport { d as defineBoot } from "../server-entry.js";
. So, it produces a cyclic dependency, which matches the description in the Node bug linked above.Old description
Title: Gracefully handle boot file errors in SSR
server-entry
uses a top-levelawait Promise.all(...)
call. So, if there is a failing boot file, the app silently exits with code 13. Even if you usenode --trace-warnings index.js
, you don't get much useful info because the file consists of a single line for minification reasons.client-entry
template usesPromise.allSettled
to load the boot files, then prints an error in case of an error. So, we should adjust theserver-entry
template to do the same.This can be put in to the app-vite v2 / app-webpack v4, then also be ported back to app-vite v1 / app-webpack v3.
The text was updated successfully, but these errors were encountered: