fix(functions/emulator): hidden-path ignore relative to functionsDir#10410
Open
kyungseopk1m wants to merge 1 commit intofirebase:mainfrom
Open
fix(functions/emulator): hidden-path ignore relative to functionsDir#10410kyungseopk1m wants to merge 1 commit intofirebase:mainfrom
kyungseopk1m wants to merge 1 commit intofirebase:mainfrom
Conversation
… functionsDir chokidar's ignored matcher was evaluating the hidden-segment regex against the absolute file path. When the project was located under a dot-prefixed ancestor directory (e.g. `.worktrees/`, `.cache/`), every file change was silently filtered out and the emulator never reloaded triggers. Match against the path relative to `backend.functionsDir` instead so that the hidden-segment rule only hides dot-prefixed entries inside the watched directory. The other built-in ignore patterns and user-supplied `backend.ignore` globs are unchanged. Fixes firebase#10187
Contributor
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in the Functions emulator where the file watcher would silently ignore changes if the project path contained a dot-prefixed ancestor directory (e.g., .worktrees/). The fix introduces a shouldIgnoreWatchPath utility that evaluates file paths relative to the functions directory before checking for hidden segments, ensuring that hidden ancestors do not trigger the ignore rule. Comprehensive unit tests were added to src/emulator/functionsEmulatorShared.spec.ts to cover various path scenarios. I have no feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #10187.
FunctionsEmulatorconfigures chokidar'signoredoption with a hidden-segment regex (/(^|[\/\\])\../) that was evaluated against the absolute file path. When the project lives under a dot-prefixed ancestor directory (for example.worktrees/,.cache/, or any other ancestor starting with.), that regex matches the ancestor segment of every path and the watcher silently filters out every change. The result is that saving a source file never triggers a reload.This change extracts a
shouldIgnoreWatchPath(functionsDir, filePath)helper infunctionsEmulatorShared.tsthat computespath.relative(functionsDir, filePath)and only tests the hidden-segment regex against the relative path. The matcher infunctionsEmulator.tsuses that helper in place of the bare regex.Behavior is preserved for the common case — files like
.git/HEAD,.dart_tool/…, or.cache/…inside the watched directory are still ignored, because their relative path starts with a dot. The remaining built-in ignore patterns (.logfiles,node_modules,venv) and any user-suppliedbackend.ignoreglobs are unchanged.Scenarios Tested
Added unit tests in
src/emulator/functionsEmulatorShared.spec.tscovering:.git/HEAD) is still ignored.src/.cache/module.js) is still ignored./home/user/.worktrees/project/functions/src/index.ts) is not ignored — the regression fix.lib/handlers/index.js) is not ignored..git/HEADand still watchessrc/index.ts.Also verified:
npm run lint:quietpasses (eslint + prettier).npm run buildpasses.npx mocha src/emulator/functionsEmulatorShared.spec.ts— 20 passing (13 existing + 7 new).Sample Commands
Not applicable — internal emulator behavior, no public CLI surface change.