diff --git a/.changeset/tough-laws-bake.md b/.changeset/tough-laws-bake.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/tough-laws-bake.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/tests/workflow-tengo/src/v2/effect.test.ts b/tests/workflow-tengo/src/v2/effect.test.ts index 434a87beec..b4fbadeaab 100644 --- a/tests/workflow-tengo/src/v2/effect.test.ts +++ b/tests/workflow-tengo/src/v2/effect.test.ts @@ -287,18 +287,25 @@ tplTest.concurrent( args: { sources: [source] }, }); - // The effect map, the imports map and the entry have locked inputs when the body returns. - // The import error gets to them later: first to the entry, then to the imports map, then to - // the effect map. Thus wait until the effect map is ready or has an error. If you do not wait, - // the client can read the entry before the error gets to it, and the read gives no error. - const effect = awaitStableState( - render.computeOutput("effect", (a) => { - if (a === undefined || !a.getIsReadyOrError()) return undefined; - return input(input(a, "imports"), source)?.listInputFields(); - }), - OUTPUT_TIMEOUT, - ); - await expect(effect).rejects.toThrow(/\/imports"[\s\S]*no-such-file\.txt[\s\S]*item not found/); + // The import error climbs one level at a time: entry, imports map, effect map. The client + // takes a field with no error as stable, so one read can end before the error or below the top. + const readError = async (): Promise => { + try { + await awaitStableState( + render.computeOutput("effect", (a) => { + input(input(a, "imports"), source)?.listInputFields(); + return undefined; + }), + OUTPUT_TIMEOUT, + ); + return undefined; + } catch (e) { + return String(e); + } + }; + await expect + .poll(readError, { timeout: OUTPUT_TIMEOUT, interval: 500 }) + .toMatch(/\/imports"[\s\S]*no-such-file\.txt[\s\S]*item not found/); }, );