QwikDev / qwik

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

[🐞] `qwik-build` loses environment variables during parallel builds #6956

Open CharlesStover opened 1 month ago

CharlesStover commented 1 month ago

Which component is affected?

Starters / CLI

Describe the bug

I am running parallel qwik builds via concurrently "PUBLIC_A=1 qwik build" "PUBLIC_A=2 qwik build".

I'm expecting my build output to have PUBLIC_A be 1 and 2 for the first and second builds respectively.

Instead, PUBLIC_A is 1 for the first build's client, then 2 for all subsequent builds (e.g. first build's server build).

It appears that in run-build-command.ts calls execaCommand, the spawned instance uses the latest environment variable values instead of the current process's values.

Reproduction

N/A

Steps to reproduce

No response

System Info

N/A

Additional Information

I assume this is fixable by replacing env: { FORCE_COLOR: true } with env: { ...process.env, FORCE_COLOR: true }, so that the subsequent build.* tasks inherit the current environment variables instead of attempting to read the way they've changed since this process was run.

Sorry about the lack of repro URL. It would simply take too long to setup.

CharlesStover commented 1 month ago

I've tried setting the environment variables before every script: build.client, build.server, and build.types. When I console.log the environment variables in vite.config, I can see that they're accurate.

They don't appear to be lost until this step: Starting Qwik City SSG...

It must be specifically Qwik City SSG that is losing the context of the current process's environment.