QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.45k stars 1.26k forks source link

[✅] fixes for all "Error: Missing Qwik City Env Data" #6237

Open PatrickJS opened 1 month ago

PatrickJS commented 1 month ago

(If you never seen this error then ignore this)

This is a live thread for different ways to fix Error: Missing Qwik City Env Data which can be caused by many different errors.

Error: Missing Qwik City Env Data
    at AsyncFunction.Aa (file:///Temp/server/q-DNo4f3Gn.js:15:11868)
    at AsyncFunction.dc (file:///Temp/server/q-DNo4f3Gn.js:10:5874)
    at AsyncFunction.V (file:///Temp/server/q-DNo4f3Gn.js:10:5808)
    at file:///Temp/server/q-DNo4f3Gn.js:15:2935
    at q (file:///Temp/server/q-DNo4f3Gn.js:7:1510)
    at file:///Temp/server/q-DNo4f3Gn.js:15:2804
    at file:///Temp/server/q-DNo4f3Gn.js:8:4693
    at Qt (file:///Temp/server/q-DNo4f3Gn.js:7:1430)
    at Et (file:///Temp/server/q-DNo4f3Gn.js:8:4686)
    at wi (file:///Temp/server/q-DNo4f3Gn.js:8:9122)

Your error might be one of the many fixes listed below

if any of these fixed your issue add a reaction to this post. Otherwise add a comment if you're still stuck

1. cookie issue

"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"

clear cookies and site data

2. accidentally importing server-only packages on the client

you might have accidentally imported a server-only package onto the client during development.

move server-only code into routeLoader$ or server$

3. deps in "dependencies" not in "devDependencies"

you might have dependencies in "dependencies" inside package.json that are being excluded. Move the packages into "devDependencies" unless they're server-only packages or packages with production binary e.g "bcrypt"

move app dependencies in package.json into "devDependencies"

4. when resizing window on local dev

sometimes when installing a new qwik app you may see this error when resizing the window. This is sometimes caused when the source-maps aren't loading

restart the dev server (comment here and ping me if this doesn't work)

5. partytown install

when installing qwik party town there can be an error with the QwikPartyTown component

remove<QwikPartytown forward={['dataLayer.push', 'fbq']} /> in root.tsx

Nefcanto commented 1 month ago

@PatrickJS, thank you for creating this thread. But I think it's not a good idea to expect developers to memorize the list you presented. The correct way is to give correct messages. Please let me repeat myself:

The right way is to give correct error messages

That's the first line for troubleshooting and debugging.

PatrickJS commented 1 month ago

yes, this is only temporary until we track down each error and fix them. The error itself is triggered more often by other errors (which we need to correctly capture)

seanperez-xyz commented 1 month ago

happens all the time in firefox... if you open up devtools automatically does that

seanperez-xyz commented 1 month ago

there was alot of errors before in dev mode that dont pop up anymore... they still do in the console but before there was an error about some image thing that the dev tools injects some container ( it would mess up my css all the time) maybe whatever was done to mute that started throwing this errors ?

PatrickJS commented 1 month ago

What's the reproduction? Is it just new qwik app 1.5.5 and open dev mode in Firefox

seanperez-xyz commented 1 month ago

What's the reproduction? Is it just new qwik app 1.5.5 and open dev mode in Firefox

well i just got 1.5.5 and it does the same thing but 15.4 did it do

PatrickJS commented 1 month ago

@JerryWu1234 do you have time to look into this bug?

JerryWu1234 commented 1 month ago

@JerryWu1234 do you have time to look into this bug?

Ok I can do

JerryWu1234 commented 4 weeks ago

image everything is fine . @seanperez-xyz Could you reproduce this bug ?

gustavocadev commented 1 week ago

It happens to me when I use a context provider in the main layout

redoPop commented 1 week ago

I just saw another instance of this error triggered when using a hook that returned a single property from a context-bound Store:

export const useFoo = () => {
  const store = useContext(MyContext);
  return store.foo;
};

The issue was resolved by abandoning the hook and instead retrieving and destructuring the complete store within components:

const { foo } = useContext(MyContext);
brunsten commented 5 days ago

I just got it in a new app with

node -v
> v18.17.1 

npm create qwik@latest
npx qwik add fastify

And if i hit a 404 route, i.e posting via postman to a random endpoint - i dont get a 404 and instead i get this error.

devcaeg commented 4 days ago

Qwik version 1.6 is causing this error to appear constantly in my application.

wmertens commented 4 days ago

@devcaeg in dev mode or production? Could you make a repro?

7ojo commented 3 days ago

After upgrading to 1.6 seems I can not also get rid off this. Dev mode.

I have to re-run "npm start" on every change.

devcaeg commented 3 days ago

It happens to me in development mode and it is constantly. For the moment I will go back to the previous version, since version 1.6 makes it impossible for me to work.

I will try to make a minimal reproduction of the error so that it can be investigated.

wmertens commented 2 days ago

@gioboa I'm also experiencing it but when I revert the assetsDir commit, I don't experience this any more

wmertens commented 2 days ago

@gioboa I take that back, it's still broken. Not sure why it worked for a bit.

frankroc2022 commented 1 day ago

Went back from 1.6 to 1.5.7. If I have no route [...catchall] I get the same error "Missing Qwik City Env Data for help visit https://github.com/QwikDev/qwik/issues/6237" but If I have a [...catchall] route I get this error "TypeError: error loading dynamically imported module: http://localhost:5173/src/components/ts/global_component_4w7djkoecc8.js%3Ft%3D1719875176718". A fresh 1.6 install has not these problems.

gioboa commented 1 day ago

Went back from 1.6 to 1.5.7. If I have no route [...catchall] I get the same error "Missing Qwik City Env Data .....

Can you share with us your repo with the bere minimum stuffs? I would like to face this error because it is so annoying

devcaeg commented 1 day ago

@wmertens @gioboa

I have created a "minimal" reproduction of the problem.

Go to Stackblitz, and navigate between HOME and LOGIN, make some changes to the files and you will see that at various times the error "Missing Qwik City Env Data" will appear.

https://stackblitz.com/edit/qwik-starter-hakacd?file=src%2Froutes%2Flayout.tsx

PS: The way I have been able to reproduce the error, is to navigate a couple of times between HOME and LOGIN, and then change the text of the "Link" and there appears the error.

devcaeg commented 1 day ago

Apart from this error, another error "Failed to fetch dynamically imported module" is also being displayed.

devcaeg commented 1 day ago

As an extra comment, since version 1.6 inside the "entry.ssr" file using "opts.serverData?.qwikcity?.ev?.sharedMap" sometimes returns "undefiend" in previous versions it never returned "undefiend".

gioboa commented 1 day ago

Thanks @devcaeg

CristianMR commented 1 day ago

PS: The way I have been able to reproduce the error, is to navigate a couple of times between HOME and LOGIN, and then change the text of the "Link" and there appears the error.

I'm encountering the same issue. Since version 1.6.0, after making just two or three changes, sometimes with as little as two lines of code, I receive the error message: Failed to fetch dynamically imported module. Restarting npm run dev temporarily resolves the problem, but it's becoming a nightmare.

devcaeg commented 1 day ago

@CristianMR

For the moment I recommend downgrading to version 1.5.7.

sprappcom commented 9 hours ago

i just had this issue and i did the CTRL+C to npm start and restart it. then it's gone. using the latest qwik

ubuntu 24.04, chrome / brave browser

incognito mode too (i thought it was something with my browser cache but it's the server side)

wmertens commented 8 hours ago

I'm encountering it when hot reloading. First render, everything is fine, but change some code, and Vite re-runs entry.ssr without providing a request and then the qwik city server data is missing.

Probably the fix is to have module.hot.accept in the right places

sprappcom commented 7 hours ago

@wmertens is there a quick fix i can do now? what do u mean module.hot.accept in the right places?

i'm having this issue persistently. i need to CTRL+C my npm start and restart it again instead of having hot reload

devcaeg commented 7 hours ago

@sprappcom

In the meantime use version 1.5.7 instead of 1.6.