Skip to content

fix: always load .env.local values in run-wrangler#14

Merged
tianma-if merged 2 commits into
tianma-if:mainfrom
0xfelixli:fix/bun-env-hash-loading
Jul 11, 2026
Merged

fix: always load .env.local values in run-wrangler#14
tianma-if merged 2 commits into
tianma-if:mainfrom
0xfelixli:fix/bun-env-hash-loading

Conversation

@0xfelixli

Copy link
Copy Markdown
Contributor

Summary

When running with Bun, .env.local is automatically loaded into process.env
before scripts/run-wrangler.mjs executes.

For PBKDF2 hashes like:

EDGE_EVER_AUTH_PASSWORD_HASH=pbkdf2-sha256$100000$...

Bun preloads the value as:

pbkdf2-sha256

As a result, loadLocalEnv() skips overriding the existing environment
variable because of:

if (process.env[key] === undefined) {
  process.env[key] = value;
}

This causes:

  • .env.wrangler.generated.secrets to contain only pbkdf2-sha256
  • wrangler secret put to upload an invalid password hash
  • authentication to always fail after deployment.

Fix

Always overwrite process.env with the value parsed from .env.local.

This keeps the custom parser authoritative and avoids runtime-specific behavior
introduced by Bun's automatic dotenv loading.

Reproduction

  1. Put a PBKDF2 hash into .env.local
EDGE_EVER_AUTH_PASSWORD_HASH=pbkdf2-sha256$100000$...
  1. Run
bun run deploy

Before this change:

.env.wrangler.generated.secrets

EDGE_EVER_AUTH_PASSWORD_HASH=pbkdf2-sha256

After this change:

EDGE_EVER_AUTH_PASSWORD_HASH=pbkdf2-sha256$100000$...

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 11, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
edgeever 1fd06da Commit Preview URL

Branch Preview URL
Jul 11 2026, 05:45 PM

@tianma-if tianma-if merged commit 498275f into tianma-if:main Jul 11, 2026
1 check passed
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