mirror of
https://github.com/hanzo-inc/tabs.git
synced 2026-11-22 10:01:17 +00:00
Cause
- Tabs showed grey placeholder cards for as long as a read of the registry
(targets, sessions) or the plan hung: the reads had no deadline, and the
skeleton shows until one read lands or fails.
- Starting a cloud terminal leases a sandbox before its pane connects. When the
pane then failed ("The terminal did not come up") the sandbox kept running,
and counting against the lease, with nothing on screen saying so; closing the
pane was the only control.
Change
- Each read carries a 15s AbortSignal.timeout, so a hang fails into the
existing error banner and its Try again.
- The failed pane names the machine, says it is still running, and has a Stop
machine button. Stopping parks the sandbox with POST /v1/sandbox/:id/pause,
the call @hanzo/app already makes for desktops; useFleet exposes it as `stop`
and Workspace takes it as the optional `onStop`.
- package.json 0.1.17 -> 0.1.18.
Testing
- tsc --noEmit: clean.
- jest (whole suite): 6 suites, 107 tests passed, including tests/timeout.test.ts.
- Not run: Playwright e2e, and the change in a browser.
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { machines, READ_TIMEOUT } from '../lib/api';
|
|
import { streams } from '../lib/plan';
|
|
|
|
/**
|
|
* A registry read that never answers held the workspace on its skeleton for
|
|
* good. Every read now carries a deadline, so a hang becomes the error state
|
|
* (and its retry) instead.
|
|
*/
|
|
describe('registry reads have a deadline', () => {
|
|
const hang = (ctl: AbortController) => {
|
|
jest.spyOn(AbortSignal, 'timeout').mockReturnValue(ctl.signal);
|
|
global.fetch = ((_u: string, init?: RequestInit) =>
|
|
new Promise((_res, rej) => {
|
|
init?.signal?.addEventListener('abort', () => rej(new Error('timed out')));
|
|
})) as unknown as typeof fetch;
|
|
};
|
|
afterEach(() => jest.restoreAllMocks());
|
|
|
|
it('gives a read that never answers a signal, and fails when it fires', async () => {
|
|
const ctl = new AbortController();
|
|
hang(ctl);
|
|
const read = machines('t');
|
|
ctl.abort();
|
|
await expect(read).rejects.toThrow('timed out');
|
|
expect(AbortSignal.timeout).toHaveBeenCalledWith(READ_TIMEOUT);
|
|
});
|
|
|
|
it('does the same for the plan read', async () => {
|
|
const ctl = new AbortController();
|
|
hang(ctl);
|
|
const read = streams('t');
|
|
ctl.abort();
|
|
await expect(read).rejects.toThrow('timed out');
|
|
});
|
|
});
|