Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe edge-function registry now watches targeted edge-function directories instead of the project root. It tracks external dependencies from the processed module graph and updates the watcher as dependencies change. Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
📊 Benchmark resultsComparing with d4945e2
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lib/edge-functions/registry.ts (1)
713-737: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winResync the root directory watcher when
edgeFunctionsDirectorieschanges.
setupFunctionsWatcher()is only called fromsetupWatchers(), sofunctionsWatcherkeeps the initial edge-function directories. The config-file watcher updates declarations and detects added/deleted functions, but it never changesfunctionsWatcher’s watched paths. Ifbuild.edge_functionstargets a new directory duringnetlify dev, files in that directory are not watched, so live reload stops working for it until the CLI restarts. Recompute and recreatefunctionsWatcherwhenedgeFunctionsDirectorieschanges after a config reload.🤖 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/lib/edge-functions/registry.ts` around lines 713 - 737, Update the config reload callback in setupWatchers so it compares the reloaded edgeFunctionsDirectories with the currently watched directories and recreates functionsWatcher when they differ. Reuse setupFunctionsWatcher (and clean up or replace the existing watcher as appropriate) after updating declarations, while preserving the existing checkForAddedOrDeletedFunctions flow.
🤖 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.
Outside diff comments:
In `@src/lib/edge-functions/registry.ts`:
- Around line 713-737: Update the config reload callback in setupWatchers so it
compares the reloaded edgeFunctionsDirectories with the currently watched
directories and recreates functionsWatcher when they differ. Reuse
setupFunctionsWatcher (and clean up or replace the existing watcher as
appropriate) after updating declarations, while preserving the existing
checkForAddedOrDeletedFunctions flow.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 19b3f024-c1b6-48c2-94ac-05c41fe6a733
📒 Files selected for processing (4)
src/lib/edge-functions/registry.tssrc/utils/multimap.tstests/unit/lib/edge-functions/watch-ignore.test.tstests/unit/lib/edge-functions/watchers.test.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
netlify/blueprints(manual)
Summary
Fixes an issue where netlify dev would fail to load or reload Edge Functions with spawn EBADF in large projects, particularly on macOS with Node 24+ (RUN-2836).
To support live reloading of Edge Functions, the CLI watched the entire project directory for file changes. On macOS, the file watcher consumes one file descriptor per watched file, so in projects with many thousands of files this pushed the process to tens of thousands of open descriptors. Once past that point, spawning any child process on macOS fails with EBADF - regardless of the configured file descriptor limit - which meant the Deno process that runs Edge Functions locally could not be started or restarted. The result was a dev server that either failed to load Edge Functions at startup or crashed when reloading them after a file change.
The fix: Instead of watching the whole project, the dev server now only watches the directories where Edge Functions live, plus the specific local files that functions import from elsewhere in the project. That import list is refreshed after every rebuild, so live reloading keeps working for functions and their dependencies - including files outside the functions directories - while the number of watched files (and open file descriptors) stays small and independent of project size.