Closed Nefcanto closed 6 months ago
This sounds like some sort of import order issue maybe? Not sure how your additions cause this to break.
It's probably happening here, which uses useQwikCityEnv, which uses useServerData, which is injected into the render function by qwik-city here which generates it from the incoming requests here.
@wmertens, because we want to have dynamic settings, one thing we tried was to return a function that returns the render function in entry.ssr.tsx
. In other words, converting this:
export default function (opts: RenderToStreamOptions) {
return renderToStream(<Root />, {
manifest,
...opts,
// Use container attributes to set attributes on the html tag.
containerAttributes: {
lang: opts.serverData?.locale || "en",
...opts.containerAttributes,
},
});
}
to this:
export default function (props) {
function render(opts: RenderToStreamOptions) {
return renderToStream(<Root {...props} />, {
manifest,
...opts,
containerAttributes: {
lang: opts.serverData?.locale || "en",
...opts.containerAttributes,
},
});
}
return render(props)
}
And changing this line in entry.express.ts
, from this:
const { router, notFound } = createQwikCity({ render, qwikCityPlan, manifest });
to this:
const props = {} // reading settings dynamically in express layer, rather than Qwik layer when the app wants to start
const render = renderer(props)
const { router, notFound } = createQwikCity({ render, qwikCityPlan, manifest });
And that caused this error. But that's a totally valid JavaScript code. What could be wrong here?
Seems ok, you'll have to step through it to figure it the problem.
@wmertens, I have done it a couple of times. But I can't find out the problem. That's why I have submitted an issue. The error is very vague.
Myeah, better to do the dynamic environment like I explained in the other issue.
This happens to me when opening the console in the devtools of Firefox with this additional warning in the console:
Source map error: Error: NetworkError when attempting to fetch resource.
Resource URL: moz-extension://356a5cca-d12d-4591-83bc-b31caa7d6363/inject.js
Source Map URL: inject.js.map
This is happening to me with a fresh install when I add <QwikPartytown forward={['dataLayer.push', 'fbq']} />
to the root.tsx
export default component$(() => {
/**
* The root of a QwikCity site always start with the <QwikCityProvider> component,
* immediately followed by the document's <head> and <body>.
*
* Don't remove the `<head>` and `<body>` elements.
*/
return (
<QwikCityProvider>
<head>
<meta charSet="utf-8" />
<link rel="manifest" href="/manifest.json" />
<QwikPartytown forward={['dataLayer.push', 'fbq']} /> <---- If I remove this line, the error goes away
<RouterHead />
</head>
<body lang="en">
<RouterOutlet />
<ServiceWorkerRegister />
</body>
</QwikCityProvider>
);
});
I ran into this when using QwikPartytown integration as well. Here's a reproduction: https://stackblitz.com/edit/qwik-starter-7l7lf7?file=src%2Froot.tsx
The above link only runs into an error when you click the reload icon. You'll be able to see the error in terminal.
I faced the same issue, but it was only due to the hostname/domain (localhost) having data of previous app stored in it. It solved itself when I cleared cookies and site data
I faced the same issue, but it was only due to the hostname/domain (localhost) having data of previous app stored in it. It solved itself when I cleared cookies and site data
This fixed the issue for me aswell. Thanks
closing this for https://github.com/QwikDev/qwik/issues/6237
I ran into this when using QwikPartytown integration as well. Here's a reproduction: https://stackblitz.com/edit/qwik-starter-7l7lf7?file=src%2Froot.tsx
The above link only runs into an error when you click the reload icon. You'll be able to see the error in terminal.
this link is right. no error in this link
Which component is affected?
Qwik Runtime
Describe the bug
I'm trying to load settings and configuration dynamically. I want to not use
.env
and.env.production
file to prevent settings being injected and hardcoded into the build output.I have tried to use
fs
to read settings. It works in the development environment. But when I go to the production, I get this error:Reproduction
https://github.com/Nefcanto/QwikMissingQwikCityEnvData
Steps to reproduce
git clone http://github.com/Nefcanto/QwikMissingQwikCityEnvData
cd QwikMissingQwikCityEnvData
npm install --legacy-peer-deps
npm run dev
https://localhost:5173
npm run build
node server/entry.express.js
System Info
Additional Information
We have three different modes for Qwik: dev, preview, and build. Based on our experience, these differ from each other. Please make them work as much the same as possible. If something works using
npm run dev
it should work fornpm run build
.