Skip to content

fix(cloudflare): auto-add .wrangler/state/v3 to .gitignore on default persistDir#4258

Open
jel-massih wants to merge 1 commit into
nitrojs:mainfrom
jel-massih:fix/cloudflare-dev-gitignore-fix
Open

fix(cloudflare): auto-add .wrangler/state/v3 to .gitignore on default persistDir#4258
jel-massih wants to merge 1 commit into
nitrojs:mainfrom
jel-massih:fix/cloudflare-dev-gitignore-fix

Conversation

@jel-massih
Copy link
Copy Markdown

@jel-massih jel-massih commented May 11, 2026

In Cloudflare dev emulation, Nitro tries to auto-append .wrangler/state/v3 to the project .gitignore so Wrangler emulator state doesn't get committed.

The guard compares a resolved absolute path against the relative literal ".wrangler/state/v3", so it never matches and the entry is never added. Switching to !config.persistDir makes the check fire when the user is on the default location.

(Also removed dead commented code but can keep that if preffered.)

…istDir

The guard compared a resolved absolute path against the bare relative
literal ".wrangler/state/v3", so the .gitignore was never updated. Gate
on whether the user customized config.persistDir instead.
@jel-massih jel-massih requested a review from pi0 as a code owner May 11, 2026 03:14
@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

@jel-massih is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The Cloudflare dev preset now conditionally updates .gitignore for the Wrangler persist directory only when config.persistDir is not explicitly provided. This replaces the prior check that compared the computed persistDir path against the default value.

Changes

Cloudflare Dev Preset Gitignore Gating

Layer / File(s) Summary
Conditional Gitignore Update Gating
src/presets/cloudflare/dev.ts
The .gitignore entry for the Wrangler persist directory is now injected only when gitIgnorePath exists and config.persistDir is not explicitly provided, instead of checking whether the computed persistDir equals the default ".wrangler/state/v3".

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with 'fix' prefix and clearly describes the main change: auto-adding .wrangler/state/v3 to .gitignore when using default persistDir.
Description check ✅ Passed The description is directly related to the changeset, explaining the bug fix for the .gitignore guard condition and how it was resolved.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/presets/cloudflare/dev.ts (1)

1-1: ⚡ Quick win

Use pathe instead of node:path for cross-platform compatibility.

Per coding guidelines, prefer pathe for path operations to ensure cross-platform compatibility. Replace the node:path import and usage with pathe.

♻️ Proposed refactor
-import { resolve } from "node:path";
+import { resolve } from "pathe";

As per coding guidelines: "Use pathe for cross-platform path operations instead of node:path"

Also applies to: 49-49

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/presets/cloudflare/dev.ts` at line 1, Replace the node:path import with
pathe: change any "import { resolve } from 'node:path'" to "import { resolve }
from 'pathe'" and ensure all uses of the resolve function in this module (e.g.,
any resolve(...) calls) continue to work by importing from pathe; also update
any other occurrences in this file that import from 'node:path' to use 'pathe'
instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/presets/cloudflare/dev.ts`:
- Line 1: Replace the node:path import with pathe: change any "import { resolve
} from 'node:path'" to "import { resolve } from 'pathe'" and ensure all uses of
the resolve function in this module (e.g., any resolve(...) calls) continue to
work by importing from pathe; also update any other occurrences in this file
that import from 'node:path' to use 'pathe' instead.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2bec4f4e-9637-414a-83a2-a2b70c5cff68

📥 Commits

Reviewing files that changed from the base of the PR and between d2e6490 and 50f5902.

📒 Files selected for processing (1)
  • src/presets/cloudflare/dev.ts

@Montiwa11
Copy link
Copy Markdown

src/presets/cloudflare/dev.

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