Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/nx/src/daemon/server/outputs-tracking.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { EventType } from '../../native';
import {
_enableOutputsTrackingForTesting,
_outputsHashesMatch,
_recordOutputsHash,
disableOutputsTracking,
outputsHashesMatchBatch,
processFileChangesInOutputs,
} from './outputs-tracking';

Expand Down Expand Up @@ -51,4 +54,19 @@ describe('outputs tracking', () => {
);
expect(_outputsHashesMatch(['dist/app/app1'], '123')).toBe(true);
});

it('should return conservative misses when output tracking is disabled', () => {
_recordOutputsHash(['dist/app/conservative'], 'hash');
disableOutputsTracking();

try {
expect(
outputsHashesMatchBatch([
{ outputs: ['dist/app/conservative'], hash: 'hash' },
])
).toEqual([false]);
} finally {
_enableOutputsTrackingForTesting();
}
});
});
4 changes: 4 additions & 0 deletions packages/nx/src/daemon/server/outputs-tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,7 @@ export function recordOutputsHashBatch(
export function disableOutputsTracking() {
disabled = true;
}

export function _enableOutputsTrackingForTesting() {
disabled = false;
}
11 changes: 10 additions & 1 deletion packages/nx/src/daemon/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,16 @@ export async function startServer(): Promise<Server> {
// this triggers the storage of the lock file hash
daemonIsOutdated();

if (!getOutputWatcherInstance()) {
if (isWindows) {
// ReadDirectoryChangesW requires a HANDLE and completion semaphore
// for every non-recursive directory watch. Output tracking is an
// optimization, so prefer conservative cache misses on Windows
// instead of a second workspace-wide watcher.
disableOutputsTracking();
serverLogger.watcherLog(
'Output tracking disabled on Windows to bound daemon HANDLE usage'
);
} else if (!getOutputWatcherInstance()) {
storeOutputWatcherInstance(
await watchOutputFiles(server, handleOutputsChanges)
);
Expand Down