qwik icon indicating copy to clipboard operation
qwik copied to clipboard

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

Open PatrickJS opened this issue 1 year ago • 57 comments
trafficstars

(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

PatrickJS avatar May 06 '24 03:05 PatrickJS

@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.

Nefcanto avatar May 06 '24 06:05 Nefcanto

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)

PatrickJS avatar May 06 '24 06:05 PatrickJS

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

seanperez-xyz avatar May 24 '24 02:05 seanperez-xyz

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 ?

  • i like adding grid directly to the body... so i remember that error it was like a container that was like 0px x 0px would sit up in the top left and actually had a flag (tooltip-ish ordeal) that would always be there saying something about image needed width height... but even if you had no images ( pertained to the container itself) it would be there... but that thing would mess up my whole css, but I notice the console, still logs the error... but that little "flag "doesnt show up on the top left, but def when you open up dev tools in firefox the second you open it up it throws the qwik.env error ... something strange tho when in dev mode the vite and qwik trys to throw a bunch of stuff in which is ignored by firefox ( like all the -web kit stuff) .. just kind of seems like thats an "Env" thing + that new qwik.env.d.ts file I keep asking what its about but no one knows

seanperez-xyz avatar May 24 '24 03:05 seanperez-xyz

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

PatrickJS avatar May 24 '24 03:05 PatrickJS

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

seanperez-xyz avatar May 24 '24 03:05 seanperez-xyz

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

PatrickJS avatar May 25 '24 18:05 PatrickJS

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

Ok I can do

JerryWu1234 avatar May 25 '24 23:05 JerryWu1234

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

JerryWu1234 avatar Jun 04 '24 01:06 JerryWu1234

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

salemgst avatar Jun 25 '24 14:06 salemgst

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);

redoPop avatar Jun 26 '24 01:06 redoPop

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.

brunsten avatar Jun 28 '24 06:06 brunsten

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

devcaeg avatar Jun 29 '24 04:06 devcaeg

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

wmertens avatar Jun 29 '24 09:06 wmertens

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.

7ojo avatar Jun 30 '24 12:06 7ojo

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.

devcaeg avatar Jun 30 '24 20:06 devcaeg

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

wmertens avatar Jul 01 '24 00:07 wmertens

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

wmertens avatar Jul 01 '24 08:07 wmertens

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.

frankroc2022 avatar Jul 01 '24 23:07 frankroc2022

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

gioboa avatar Jul 01 '24 23:07 gioboa

@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 avatar Jul 02 '24 02:07 devcaeg

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

devcaeg avatar Jul 02 '24 02:07 devcaeg

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

devcaeg avatar Jul 02 '24 02:07 devcaeg

Thanks @devcaeg

gioboa avatar Jul 02 '24 02:07 gioboa

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.

CristianMR avatar Jul 02 '24 15:07 CristianMR

@CristianMR

For the moment I recommend downgrading to version 1.5.7.

devcaeg avatar Jul 02 '24 15:07 devcaeg

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)

sprappcom avatar Jul 03 '24 11:07 sprappcom

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

wmertens avatar Jul 03 '24 12:07 wmertens

@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

sprappcom avatar Jul 03 '24 14:07 sprappcom

@sprappcom

In the meantime use version 1.5.7 instead of 1.6.

devcaeg avatar Jul 03 '24 14:07 devcaeg