mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-03-30 14:45:52 +00:00
perf: 200ms gap between pre-warm requests to drain client queue
setImmediate wasn't enough — each analytics computation blocks for 200-400ms synchronously. Adding a 200ms setTimeout between pre-warm requests gives pending client requests a window to complete between the heavy computations.
This commit is contained in:
@@ -3008,8 +3008,9 @@ server.listen(listenPort, () => {
|
||||
if (isHttps) requestOptions.rejectUnauthorized = false;
|
||||
warmClient.get(requestOptions, (res) => {
|
||||
res.resume();
|
||||
res.on('end', () => setImmediate(warmNext)); // yield to event loop between warm requests
|
||||
}).on('error', () => setImmediate(warmNext));
|
||||
// 200ms gap between warm requests — lets pending client requests drain
|
||||
res.on('end', () => setTimeout(warmNext, 200));
|
||||
}).on('error', () => setTimeout(warmNext, 200));
|
||||
};
|
||||
// Stagger: warm analytics after subpaths are done (sequential to avoid blocking)
|
||||
warmNext();
|
||||
|
||||
Reference in New Issue
Block a user