← Back to Pull requests

watch: track all dependencies of an owner #66139

Open
christianaurichzm opened this pull request with 31 lines diff across 2 files
View on GitHub
christianaurichzm christianaurichzm commented on Sep 19, 2026 19:47 UTC
Author

FilesWatcher#filterFile() reads #ownerDependencies with the dependency path, but writes the set back keyed by the owner. As a result, each call starts a fresh set and overwrites the previous one, so an owner keeps only the last dependency registered for it.

Each test child reports the modules it loads through watch:require/watch:import, with one filterFile() call per module. A test file with N dependencies therefore keeps 1 and loses N-1.

unfilterFilesOwnedBy() walks that set to release an owner's dependencies, so the lost dependencies remain in #filteredFiles and #dependencyOwners. A restart re-reports the modules the test still loads, which hides the stale state for those modules, but a dependency it stopped requiring is never reported again and therefore never removed:

# a.test.js requires dep1.js and dep2.js
node --test --watch a.test.js

# drop require('./dep1.js') from a.test.js   -> restarts, as expected
# touch dep1.js                              -> restarts again

The second restart should not happen: dep1.js is no longer a dependency of any test. Its stale entries otherwise remain for the lifetime of the process.

The bug was introduced with #45214 (97355c74e819), first released in v19.2.0 and later backported to v18.13.0. test-watch-file-shared-dependency does not catch it because it registers one dependency per owner, while this bug requires an owner with multiple dependencies.

The diff also stores the #dependencyOwners lookup in a local while removing an owner's dependencies, avoiding repeated map lookups for each dependency.

Refs: https://github.com/nodejs/node/pull/45214

Diff: 31 lines (+27 / -4) across 2 files Reviewer: MoLow Review duration: 41376m
All Vouch review confidence checks passed
Residual risk 0.07 = Change Risk (0.25) × (1 − Review Confidence (0.71)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.25 · 31 lines diff across 2 files
0.25
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.55 · 3 substantive comment(s)
0.55
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
70%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.207
Real PR Conversation Timeline
5 items
codecov[bot] codecov[bot] commented on Sep 19, 2026 21:25 UTC
Bot

Codecov Report


:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 90.28%. Comparing base (bca9bbe) to head (c3cc140).
:warning: Report is 443 commits behind head on main.

<details><summary>Additional details and impacted files</summary>

@@           Coverage Diff           @@
##             main   #66139   +/-   ##
=======================================
  Coverage   90.28%   90.28%           
=======================================
  Files         790      790           
  Lines      271982   271985    +3     
  Branches    51915    51921    +6     
=======================================
+ Hits       245546   245571   +25     
+ Misses      16947    16901   -46     
- Partials     9489     9513   +24     

| Files with missing lines | Coverage Δ | |
|---|---|---|
| lib/internal/watch\_mode/files\_watcher.js | 91.55% <100.00%> (+0.11%) | :arrow_up: |

... and 32 files with indirect coverage changes
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    christianaurichzm christianaurichzm commented on Oct 06, 2026 21:59 UTC
    Author

    @MoLow since this is in the FilesWatcher dependency tracking from #45214, could you take a look when you get a chance? cc @ShogunPanda. If it looks good, could you also add request-ci? Thanks!

    MoLow MoLow approved these changes on Oct 07, 2026 11:29 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    christianaurichzm christianaurichzm
    Labels
    risk: low confidence: 70.6% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 25.2% (LOW) · Higher = larger blast radius
    25.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 70.6% · Lower = rushed or shallow review
    70.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.4% · Safe to merge
    7.4%
    Repository