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

Function armableFailingProvider

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

Source from the content-addressed store, hash-verified

1220 * plainly-forked integration read's scheduler tick, so the read this test
1221 * wants hanging would never start at all. */
1222const armableFailingProvider = () => {
1223 const store = new Map<string, string>();
1224 let failWith: string | undefined;
1225 const provider: CredentialProvider = {
1226 key: ProviderKey.make("memory"),
1227 writable: true,
1228 get: (id) =>
1229 Effect.suspend(() => {
1230 if (failWith === undefined) return Effect.succeed(store.get(String(id)) ?? null);
1231 const message = failWith;
1232 // Two chained ticks, not one: the credential read launches BEFORE
1233 // the speculative integration fork is even scheduled (dominant-first
1234 // is structural), so a failure delivered on the very next tick would
1235 // interrupt that fork before it ever issued its read. The extra tick
1236 // lets the speculative read genuinely start — and hang — first, so
1237 // the test exercises "failure surfaces while the read hangs" rather
1238 // than "failure surfaces before the read exists".
1239 return Effect.promise(
1240 () =>
1241 new Promise<void>((resolve) => {
1242 setImmediate(() => setImmediate(resolve));
1243 }),
1244 ).pipe(Effect.andThen(Effect.fail(new StorageError({ message, cause: undefined }))));
1245 }),
1246 set: (id, value) => Effect.sync(() => void store.set(String(id), value)),
1247 };
1248 return {
1249 provider,
1250 failNow: (message: string) => {
1251 failWith = message;
1252 },
1253 };
1254};
1255
1256describe("speculative read abandonment", () => {
1257 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