Move Windows metrics process launches off the main thread
CI / verify (push) Canceled after 0s

This commit is contained in:
Sucukdeluxe committed 2026-10-20 14:42:55 +02:00
1 parent fe3797fd18
commit 290b9db8ce
6 files changed
+98 -4

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
const { parentPort } = require('node:worker_threads');
const { readWindowsCounters } = require('./system-metrics');
const { runtimePerformance } = require('./performance-monitor');
let active = null;
parentPort.on('message', async message => {
if (message.type === 'cancel') {
if (active?.id === message.id) active.controller.abort();
return;
}
if (message.type !== 'read' || !Number.isSafeInteger(message.id) || active) return;
const controller = new AbortController();
active = { id: message.id, controller };
let value, error = false;
try { value = await readWindowsCounters({ signal: controller.signal }); }
catch { error = true; }
const spawnMs = runtimePerformance.snapshot().operations.find(operation => operation.name === 'host.spawn.sync')?.lastMs;
active = null;
parentPort.postMessage({ id: message.id, value, error, spawnMs });
});