Repository navigation
Description
Describe the bug
After updating wxt from 0.20.20 to 0.20.21, this error is caused:
Error: Missing required config: CHROME_EXTENSION_ID, FIREFOX_EXTENSION_ID
I have these environment variables defined in the .env file.
This is probably caused by #2181
- import { config } from 'dotenv';Simply importing dotenv/config auto-imports the .env file. From the README:
// index.js require('dotenv').config() // or import 'dotenv/config' // for esm console.log(`Hello ${process.env.HELLO}`)That's it.
process.envnow has the keys and values you defined in your.envfile.
Reproduction
- https://github.com/hyunbinseo/better-surf/releases/tag/v0.0.28
- https://github.com/hyunbinseo/better-surf/actions/runs/24392573474/job/71242144892
Steps to reproduce
No response
System Info
System:
OS: Windows 11 10.0.26200
CPU: (8) x64 Intel(R) Core(TM) Ultra 7 258V
Memory: 6.69 GB / 31.48 GB
Binaries:
Node: 24.14.1 - C:\Users\hyunb\AppData\Local\fnm_multishells\6356_1776160262050\node.EXE
npm: 11.11.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\6356_1776160262050\npm.CMD
pnpm: 10.33.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\6356_1776160262050\pnpm.CMD
Deno: 2.4.0 - C:\Users\hyunb\.deno\bin\deno.EXE
Browsers:
Chrome: 147.0.7727.56
Edge: Chromium (140.0.3485.54)
Firefox: 149.0.2 - C:\Program Files\Mozilla Firefox\firefox.exeUsed Package Manager
npm
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
No labels
Activity
aklinker1 commentedon Apr 14, 2026
Very weird. Not sure why this change would have effected
wxt submit, that's an alias forpublish-browser-extension, so it's more likely a change there that broke it.WXT was never importing from
dotenv/config, it manually calledconfig(), so that's not the problem.Couple of things I noticed:
.env, butpublish-browser-extensionhas always loaded.env.submit, it's never loaded.envLooking at your lockfile, it looks like the last success was with
[email protected], and it failed after upgrading to4.0.5... Odd, that was a very small release that didn't touch env at all... Hmm, that does make me think WXT might be the cause...Regardless, you should be putting this files in
.env.submit, not.env. I'm not sure why your CI worked at all. Alternatively, you could addNODE_OPTIONS: ---env-file=.envon your submit step's environment, to have node load that file in addition to.env.submit.- name: Submit to stores run: | pnpm wxt submit \ --chrome-zip .output/*-chrome.zip \ --firefox-zip .output/*-firefox.zip --firefox-sources-zip .output/*-sources.zip env: + NODE_OPTIONS: --env-file=.env CHROME_EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }} CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }} CHROME_CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }} CHROME_REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }} FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }} FIREFOX_JWT_ISSUER: ${{ secrets.FIREFOX_JWT_ISSUER }} FIREFOX_JWT_SECRET: ${{ secrets.FIREFOX_JWT_SECRET }}hyunbinseo commentedon Apr 14, 2026
@aklinker1 thanks for the quick review.
I was using
.env.submitbriefly when I was directly usingpublish-browser-extensiondirectly:because it wasn't autoloading the
.envfile. This is why I believewxtwas importing.envin the previous version.hyunbinseo commentedon Apr 14, 2026
Isn't
.envsupposed be loaded in all cases though?https://wxt.dev/guide/essentials/config/environment-variables.html#dotenv-files
aklinker1 commentedon Apr 14, 2026
The submit commands are special, they are just aliases to
publish-browser-extension. env files are loaded when we resolve WXT's config internally, but that's not necessary to forward the CLI command to another CLI.Also note "runtime" in "And any environment variables listed inside them will be available at runtime" - the CLI is build-time, not runtime. Runtime is when the extension is running in the browser.
hyunbinseo commentedon Apr 14, 2026
Fixed in hyunbinseo/better-surf@14375f7
Maybe the behavior of
loadEnvFileinwxt.config.tschanged?The
NODE_OPTIONSsuggestion did not work: https://github.com/nodejs/node/issues/511474aklinker1 commentedon Apr 14, 2026
OK, found the problem
I modified
publish-browser-extensionto print the resolved chrome config to see whatextensionIdit resolved internally.git checkout v0.0.28git checkout v0.0.27In v0.0.27, even if the env var was set to an empty string, it worked. But in v0.0.28, if you set the env var to an empty string, it would not be overriden.
I was confused at first because my local testing couldn't reproduce the problem. But then I remembered your action is passing a blank string for the
CHROME_EXTENSION_IDenv var. You secret is empty, and it's listed here, thus a blank string. You can see this by looking at the workflow logs as well:So the PR you originally mentioned was the cause - after that PR, env vars that are blank strings are not overridden.
Specifically, if you modify WXT's
loadEnvas follows:We get the following logs:
So you can see WXT no longer applies the result of
dotenv-expandto the realprocess.env, asdotenvwas doing before.This only seems to cause issues if you have the same env var set multiple ways, once outside a
.envand once inside a.env. I think the current behavior is more correct - you clearly set the env var to a blank string when running the command, which should take priority.If we wanted to fix this, the solution would be to let
dotenv-expandmodify the realprocess.envlike so:const res = expand({ parsed, - processEnv: { ...process.env } + processEnv: process.env });Vite doesn't do this, but the package's docs imply we should 🤔
aklinker1 commentedon Apr 14, 2026
BUT vite doesn't use this to make variables available via
process.env- it uses the result to replaceimport.meta.env.*in your bundle.So I think I'll make this change.