Skip to content

Comments

fix(core): skip stale recomputations and prevent lost file changes in daemon#34424

Merged
FrozenPandaz merged 2 commits intomasterfrom
nxc-3908
Feb 18, 2026
Merged

fix(core): skip stale recomputations and prevent lost file changes in daemon#34424
FrozenPandaz merged 2 commits intomasterfrom
nxc-3908

Conversation

@leosvelperez
Copy link
Member

@leosvelperez leosvelperez commented Feb 12, 2026

Current Behavior

When file changes arrive rapidly, the daemon triggers multiple concurrent project graph recomputations that all run to completion — wasting CPU/memory on redundant work and returning stale results.

Additionally, after processing file changes, the daemon clears all tracked files indiscriminately. Files that changed mid-recomputation are silently lost and never reflected in the project graph until another unrelated file change arrives.

Expected Behavior

Stale recomputations detect when a newer one has started and exit early, chaining to the newer promise so callers always get the freshest result.

File change tracking now uses versioned maps. Each batch of file watcher events gets a unique version, and only files matching the snapshotted version are cleared after processing. Files that changed mid-recomputation are preserved and picked up by the next cycle.

@leosvelperez leosvelperez self-assigned this Feb 12, 2026
@leosvelperez leosvelperez requested a review from a team as a code owner February 12, 2026 12:59
@nx-cloud
Copy link
Contributor

nx-cloud bot commented Feb 12, 2026

View your CI Pipeline Execution ↗ for commit 7214315

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 50m 32s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 4m 9s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 7s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-13 17:17:49 UTC

@netlify
Copy link

netlify bot commented Feb 12, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 7214315
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/698f4fa5fd44e20008645ea4
😎 Deploy Preview https://deploy-preview-34424--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Feb 12, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 7214315
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/698f4fa504d74e00087f781b
😎 Deploy Preview https://deploy-preview-34424--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

return cachedSerializedProjectGraphPromise;
}

await processCollectedUpdatedAndDeletedFiles(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Double, triple check that this will indeed take the stale updated/deleted files into account.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, the changes didn't introduce new issues, but while reviewing, I did find a couple of pre-existing race conditions. So, I sent another commit to fix them too.

When file changes arrive rapidly, multiple recomputations can start concurrently. Previously all would run to completion doing redundant work.

Add a generation counter that allows in-progress recomputations to detect when a newer one has started and exit early by chaining to the newer promise.

Prevents redundant work when rapid file changes trigger overlapping recomputations.
@leosvelperez leosvelperez changed the title fix(core): skip stale recomputations in daemon fix(core): skip stale recomputations and prevent lost file changes in daemon Feb 13, 2026
@FrozenPandaz FrozenPandaz merged commit 91b350e into master Feb 18, 2026
26 checks passed
@FrozenPandaz FrozenPandaz deleted the nxc-3908 branch February 18, 2026 21:18
FrozenPandaz pushed a commit that referenced this pull request Feb 20, 2026
… daemon (#34424)

## Current Behavior

When file changes arrive rapidly, the daemon triggers multiple
concurrent project graph recomputations that all run to completion —
wasting CPU/memory on redundant work and returning stale results.

Additionally, after processing file changes, the daemon clears all
tracked files indiscriminately. Files that changed mid-recomputation are
silently lost and never reflected in the project graph until another
unrelated file change arrives.

## Expected Behavior

Stale recomputations detect when a newer one has started and exit early,
chaining to the newer promise so callers always get the freshest result.

File change tracking now uses versioned maps. Each batch of file watcher
events gets a unique version, and only files matching the snapshotted
version are cleared after processing. Files that changed
mid-recomputation are preserved and picked up by the next cycle.

(cherry picked from commit 91b350e)
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