Skip to content

fix: only watch needed env files - #1

Open
AmerAlali wants to merge 2 commits into
mainfrom
pr-15365
Open

AmerAlali wants to merge 2 commits into
mainfrom
pr-15365

Conversation

@AmerAlali

Copy link
Copy Markdown

ref: vitejs#15347

I wanted to create a test that would assert that page reload don't happen on editing (.env) in the env-nested playground, but asserting empty serverLogs is not really strong. Ideally we should be able to opt-in into debug logs on a test( suite) bases, but this would require re-loading Vite sources before each test and feels too much for such a small test

@tently-team tently-team deleted a comment from tently-review Bot Sep 18, 2026
@AmerAlali AmerAlali closed this Sep 18, 2026
@AmerAlali AmerAlali reopened this Sep 18, 2026
@AmerAlali AmerAlali closed this Sep 18, 2026
@AmerAlali AmerAlali reopened this Sep 18, 2026
@tently-review

tently-review Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

🛡️ Tently review

Found 1 finding — 🟠 1 high.


1. 🟠 getEnvFilesForMode now returns absolute paths (joined with envDir), but handleHMRUpdate still compares against fileName, which is path.basename(file). The includes() check never matches, so isEnv is always false. Changes to .env files no longer restart the dev server. The call site was updated to pa

Regression · 🟠 High · Confidence 93% · packages/vite/src/node/server/hmr.ts:77

getEnvFilesForMode now returns absolute paths (joined with envDir), but handleHMRUpdate still compares against fileName, which is path.basename(file). The includes() check never matches, so isEnv is always false. Changes to .env files no longer restart the dev server. The call site was updated to pass envDir, but the comparison still uses the basename. It should compare against file.

Evidence

packages/vite/src/node/server/hmr.ts:77

const fileName = path.basename(file)
...
const isEnv =
  config.inlineConfig.envFile !== false &&
  getEnvFilesForMode(config.mode, config.envDir).includes(fileName)

Impacted symbols: handleHMRUpdate, getEnvFilesForMode


Posted by Tently · reply with /tently … to give feedback

@AmerAlali

Copy link
Copy Markdown
Author

@tently-team/dev review this

1 similar comment
@AmerAlali

Copy link
Copy Markdown
Author

@tently-team/dev review this

@muhannadsalkini

Copy link
Copy Markdown
Member

@tently review this

1 similar comment
@AmerAlali

Copy link
Copy Markdown
Author

@tently review this

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.

4 participants