MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / armableFailingProvider

Function armableFailingProvider

packages/core/sdk/src/executor.test.ts:1332–1364  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1330 * plainly-forked integration read's scheduler tick, so the read this test
1331 * wants hanging would never start at all. */
1332const armableFailingProvider = () => {
1333 const store = new Map<string, string>();
1334 let failWith: string | undefined;
1335 const provider: CredentialProvider = {
1336 key: ProviderKey.make("memory"),
1337 writable: true,
1338 get: (id) =>
1339 Effect.suspend(() => {
1340 if (failWith === undefined) return Effect.succeed(store.get(String(id)) ?? null);
1341 const message = failWith;
1342 // Two chained ticks, not one: the credential read launches BEFORE
1343 // the speculative integration fork is even scheduled (dominant-first
1344 // is structural), so a failure delivered on the very next tick would
1345 // interrupt that fork before it ever issued its read. The extra tick
1346 // lets the speculative read genuinely start — and hang — first, so
1347 // the test exercises "failure surfaces while the read hangs" rather
1348 // than "failure surfaces before the read exists".
1349 return Effect.promise(
1350 () =>
1351 new Promise<void>((resolve) => {
1352 setImmediate(() => setImmediate(resolve));
1353 }),
1354 ).pipe(Effect.andThen(Effect.fail(new StorageError({ message, cause: undefined }))));
1355 }),
1356 set: (id, value) => Effect.sync(() => void store.set(String(id), value)),
1357 };
1358 return {
1359 provider,
1360 failNow: (message: string) => {
1361 failWith = message;
1362 },
1363 };
1364};
1365
1366describe("speculative read abandonment", () => {
1367 it.effect("unknown-tool error surfaces while the speculative reads hang forever", () =>

Callers 1

executor.test.tsFile · 0.85

Calls 3

getMethod · 0.65
syncMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected