Unify halt and fire cancellation by verified run identity with durable first-owner receipts and shared deadlines. Integrate the instance control with the current host, library and tester-socket paths. Focused nine-file evidence is 62 passing tests; broad suites, mutants and review remain pending.
23 lines
1.3 KiB
JavaScript
23 lines
1.3 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { mkdtempSync, rmSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { initializeControl, transition } from '../../processing-control/src/state.mjs';
|
|
import { withProcessing } from '../../processing-control/src/effects.mjs';
|
|
import { webService } from '../src/web.mjs';
|
|
test('a root halt aborts the active search-source signal before the normal web deadline', async t => {
|
|
const root = mkdtempSync(join(tmpdir(), 'processing-web-')); initializeControl(root);
|
|
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
let ready, observed;
|
|
const started = new Promise(resolve => { ready = resolve; });
|
|
const service = webService({ deadlineMs: 3000, search: { search: (_query, { signal }) => new Promise((_resolve, reject) => {
|
|
observed = signal; signal.addEventListener('abort', () => reject(signal.reason), { once: true }); ready();
|
|
}) } });
|
|
const call = withProcessing(root, () => service.handle('web.search', { query: 'fixture' }));
|
|
await started; const began = Date.now(); transition(root, { business: 'demo', human: 'jason', halted: true });
|
|
await call.catch(() => {});
|
|
assert.equal(observed.aborted, true); assert.equal(observed.reason.name, 'ProcessingError');
|
|
assert.ok(Date.now() - began < 1500);
|
|
});
|