Skip to content

Conversation

@roerohan
Copy link

@roerohan roerohan commented Jan 8, 2026

✘ [ERROR] Uncaught TypeError: Cannot read properties of undefined (reading 'replace') Error

      at setEnvVars

[wrangler:error] TypeError: Cannot read properties of undefined (reading 'replace')
    at async Object.fetch

If the value of the environment variable is undefined, it throws the above error. It's not easy to understand what is causing it, adding an optional chaining operator avoid the error. It is worth noting that the exportCommand will be effectively become export ${key}='undefined'.

@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2026

⚠️ No Changeset found

Latest commit: 0c5a28e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ghostwriternr
Copy link
Member

Hey @roerohan ! In terms of making this a very complete fix, I opened #342 - what do you think about the approach there? I realised thanks to your PR that there was no clear way to unset env variables anyway and maybe it should be supported proper by doing this?

@roerohan
Copy link
Author

Hey @roerohan ! In terms of making this a very complete fix, I opened #342 - what do you think about the approach there? I realised thanks to your PR that there was no clear way to unset env variables anyway and maybe it should be supported proper by doing this?

Looks good! I'm closing this one, let's merge #342 instead!

@roerohan roerohan closed this Jan 10, 2026
@roerohan roerohan deleted the patch-1 branch January 10, 2026 05:55
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.

2 participants