Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 24, 2025

Fixes #3188

Note

Coded by Copilot, reviewed by human.

Copy link

cloudflare-workers-and-pages bot commented Sep 24, 2025

Deploying wasp-docs-on-main with  Cloudflare Pages  Cloudflare Pages

Latest commit: b10385f
Status:🚫  Build failed.

View logs

…ring

Co-authored-by: infomiho <2223680+infomiho@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Build fails if process.env.NODE_ENV is typed by deps Fix NODE_ENV TypeScript duplication error in server env template Sep 24, 2025
@Copilot Copilot AI requested a review from infomiho September 24, 2025 15:43
Copilot finished work on behalf of infomiho September 24, 2025 15:43
@infomiho
Copy link
Contributor

@copilot you didn't do the equivalent change in the client code

Copy link
Contributor Author

Copilot AI commented Sep 24, 2025

@copilot you didn't do the equivalent change in the client code

Could you clarify what specific client-side change is needed? I looked at the client env template and it currently uses ensureEnvSchema(import.meta.env, clientEnvSchema) directly without the duplicate property pattern that caused the server-side issue.

The server issue was from { NODE_ENV: defaultValue, ...process.env } but the client side doesn't seem to have this pattern. Are you referring to a specific file or scenario where the client code needs the same destructuring approach?

Copilot finished work on behalf of infomiho September 24, 2025 16:05
@infomiho infomiho marked this pull request as ready for review September 25, 2025 12:16
Comment on lines 161 to 165
const { NODE_ENV = serverDevSchema.shape.NODE_ENV.value, ...restEnv } = process.env;
export const env = ensureEnvSchema(
{ NODE_ENV: serverDevSchema.shape.NODE_ENV.value, ...process.env },
{ NODE_ENV, ...restEnv },
serverEnvSchema,
)
Copy link
Member

@cprecioso cprecioso Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we declare the default value at the schema level? It seems like it would be a nice place for that. I am not in love with this solution, it's a bit of an inscrutable workaround. (but if it's needed then so be it)


At any rate, I think we could do a couple things to improve:

Suggested change
const { NODE_ENV = serverDevSchema.shape.NODE_ENV.value, ...restEnv } = process.env;
export const env = ensureEnvSchema(
{ NODE_ENV: serverDevSchema.shape.NODE_ENV.value, ...process.env },
{ NODE_ENV, ...restEnv },
serverEnvSchema,
)
const defaultNodeEnv = serverDevSchema.shape.NODE_ENV.value;
// We manually extract `NODE_ENV` to avoid a TypeScript error about overwriting it blah blah
const { NODE_ENV: inputNodeEnv, ...restEnv } = process.env;
export const env = ensureEnvSchema(
{
NODE_ENV: inputNodeEnv ?? defaultNodeEnv,
...restEnv
},
serverEnvSchema,
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed on the call, we'll change as you proposed - but we'll refactor it later on when we upgrade to Zod 4

@infomiho infomiho requested a review from cprecioso September 29, 2025 10:11
@infomiho infomiho force-pushed the copilot/fix-3584091d-5ae9-4791-a375-7224f81cbb06 branch 2 times, most recently from fc51f70 to 7b99b6a Compare September 29, 2025 10:13
@infomiho infomiho force-pushed the copilot/fix-3584091d-5ae9-4791-a375-7224f81cbb06 branch from 7b99b6a to bf5ae4e Compare September 29, 2025 10:43
@infomiho infomiho merged commit 41888e0 into main Sep 29, 2025
7 of 8 checks passed
@infomiho infomiho deleted the copilot/fix-3584091d-5ae9-4791-a375-7224f81cbb06 branch September 29, 2025 14:36
infomiho added a commit that referenced this pull request Sep 29, 2025
Co-authored-by: infomiho <2223680+infomiho@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Mihovil Ilakovac <mihovil@ilakovac.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails if process.env.NODE_ENV is typed by deps

3 participants