strand-async-helper-awaited.ts 1.3 KB

123456789101112131415161718192021222324
  1. // The control for strand-async-helper-unawaited: the same helper, awaited at its call site.
  2. // `await h()` spawns the strand and joins it in one expression, so the picture is the plain
  3. // sequential one the analyzer has always drawn — the helper's step is settled before the
  4. // middle ask issues.
  5. //
  6. // This is the fixture that says the refactor did not cost anything: a strand is a fork only
  7. // when the script actually leaves it running.
  8. //
  9. // Expected:
  10. // core — `region call#1 call parent=seq#1 … label="h" strand` (the flag rides the region
  11. // whatever the call site does with the promise) and `settle ask#1 in=seq#1 joins=call#1`
  12. // on the main line, right after the call's `jump return`. The strand is spawned while
  13. // evaluating the operand, so it joins syntactically.
  14. // causality — the sequential picture: `ask#1 -> ask#2 seq` and both feeding `ask#3` by
  15. // `data`.
  16. // cfg — no `alongside` anywhere, and `ask#1@1 -> ask#2@1 join via=return`: the strand's
  17. // exit lands on the middle ask, one node later than the `fork` that spawned it.
  18. async function h(): Promise<string> {
  19. return await agent("h").ask<string>("h");
  20. }
  21. const hv = await h();
  22. const mid = await agent("m").ask<string>("m");
  23. return await agent("l").ask<string>(hv + mid);