mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:41:22 +00:00
perf(test): trim browser smoke and speed canvas test reload
This commit is contained in:
@@ -264,6 +264,10 @@ export async function createCanvasHostHandler(
|
||||
const rootReal = await prepareCanvasRoot(rootDir);
|
||||
|
||||
const liveReload = opts.liveReload !== false;
|
||||
const testMode = opts.allowInTests === true;
|
||||
const reloadDebounceMs = testMode ? 12 : 75;
|
||||
const writeStabilityThresholdMs = testMode ? 12 : 75;
|
||||
const writePollIntervalMs = testMode ? 5 : 10;
|
||||
const wss = liveReload ? new WebSocketServer({ noServer: true }) : null;
|
||||
const sockets = new Set<WebSocket>();
|
||||
if (wss) {
|
||||
@@ -293,7 +297,7 @@ export async function createCanvasHostHandler(
|
||||
debounce = setTimeout(() => {
|
||||
debounce = null;
|
||||
broadcastReload();
|
||||
}, 75);
|
||||
}, reloadDebounceMs);
|
||||
debounce.unref?.();
|
||||
};
|
||||
|
||||
@@ -301,8 +305,11 @@ export async function createCanvasHostHandler(
|
||||
const watcher = liveReload
|
||||
? chokidar.watch(rootReal, {
|
||||
ignoreInitial: true,
|
||||
awaitWriteFinish: { stabilityThreshold: 75, pollInterval: 10 },
|
||||
usePolling: opts.allowInTests === true,
|
||||
awaitWriteFinish: {
|
||||
stabilityThreshold: writeStabilityThresholdMs,
|
||||
pollInterval: writePollIntervalMs,
|
||||
},
|
||||
usePolling: testMode,
|
||||
ignored: [
|
||||
/(^|[\\/])\../, // dotfiles
|
||||
/(^|[\\/])node_modules([\\/]|$)/,
|
||||
|
||||
Reference in New Issue
Block a user