Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(view): sample before timeout [N26,C7]

Corey Olson77d131badd73
diff --git a/test/cockpit/shared-wait.test.js b/test/cockpit/shared-wait.test.js
index cf3a05ff..56132713 100644
--- a/test/cockpit/shared-wait.test.js
+++ b/test/cockpit/shared-wait.test.js
@@ -210,3 +210,27 @@ test('the shared wait survives a redrawn element [N26,C7]', { timeout: 120_000 }
await view.stop();
}
});
+
+test('a timeout always reports the last sample [N26,C7]', { timeout: 90_000 }, async () => {
+ const executable = chromeExecutable();
+ assert.ok(executable, 'Chrome is required for the throttled timeout diagnostic');
+ const box = machine();
+ project(box, 'timeout-last-sample');
+ const view = await startView(box);
+ let chrome;
+ try {
+ chrome = await openSnapshotChrome(executable, view.link.href, join(box.dir, 'timeout-last-sample-chrome'));
+ await chrome.waitFor('!!data?.project');
+ await chrome.send('Emulation.setCPUThrottlingRate', { rate: 6 });
+ const missing = "document.querySelector('#never-sampled-proof').closest('button')";
+ await assert.rejects(() => waitForStableBoxes(chrome, missing, 1), error => {
+ assert.match(error.message, /never-sampled-proof/, 'the timeout names the missing target');
+ assert.match(error.message, /last saw.*TypeError/i, 'the 1 ms timeout includes the first sampled failure');
+ return true;
+ });
+ assert.deepEqual(chrome.exceptions, [], 'the missing target is reported without an uncaught page exception');
+ } finally {
+ if (chrome) await closeSnapshotChrome(chrome);
+ await view.stop();
+ }
+});
diff --git a/test/cockpit/stable.js b/test/cockpit/stable.js
index 6c2a9e4d..551e0c0d 100644
--- a/test/cockpit/stable.js
+++ b/test/cockpit/stable.js
@@ -47,6 +47,8 @@ export async function waitForStableBoxes(chrome, find = 'document.documentElemen
if (unchanged >= 2) { clearTimeout(timer); resolve(current.targets); return; }
frameId = requestAnimationFrame(frame);
};
+ // Sample synchronously before yielding so even an expired short timer has a real diagnostic.
+ try { sample(); } catch (error) { lastSeen = error.name + ': ' + error.message; }
frameId = requestAnimationFrame(frame);
});
})()`);