Summary
The TypeScript codegen pipeline (AtsTypeScriptCodeGenerator) has strong snapshot-based unit tests that verify the shape of generated code (73 tests). However, there are no runtime unit tests that execute the generated TypeScript logic — particularly the promise tracking and flushing infrastructure in transport.ts.
What's missing
The following runtime behaviors in src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.ts have no direct test coverage:
trackPromise() — promises are added to the set and removed on settlement
flushPendingPromises() — snapshot-based flush completes without deadlock when new promises are tracked mid-flush (e.g., by the build() PromiseImpl constructor)
- Error propagation — rejected promises are captured in
_rejectedErrors and surfaced as AggregateError during flush
- Silent error loss — promises that reject before flush is called still have their errors collected
Why this matters
A deadlock bug in flushPendingPromises() (a while loop re-awaiting a promise tracked during flush) was caught only by code review, not by any test. The fix (snapshot-based single pass) is validated only by:
- Snapshot tests — verify the generated code text matches, not that it runs correctly
- E2E tests —
aspire start would timeout on deadlock, but these are slow, Docker-dependent, and can't test subtle error handling
A targeted TypeScript unit test could deterministically reproduce the deadlock scenario and prevent regressions.
Suggested approach
Add a test file (e.g., transport.test.ts) that:
- Instantiates the promise tracking logic directly
- Tests
trackPromise + flushPendingPromises with controlled promise resolution
- Simulates the deadlock scenario: track a new promise while flush is suspended at
await
- Verifies
AggregateError is thrown when tracked promises reject
Context
Related PR: #15901 (Auto-resolve promises in TypeScript codegen)
Summary
The TypeScript codegen pipeline (
AtsTypeScriptCodeGenerator) has strong snapshot-based unit tests that verify the shape of generated code (73 tests). However, there are no runtime unit tests that execute the generated TypeScript logic — particularly the promise tracking and flushing infrastructure intransport.ts.What's missing
The following runtime behaviors in
src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/transport.tshave no direct test coverage:trackPromise()— promises are added to the set and removed on settlementflushPendingPromises()— snapshot-based flush completes without deadlock when new promises are tracked mid-flush (e.g., by thebuild()PromiseImpl constructor)_rejectedErrorsand surfaced asAggregateErrorduring flushWhy this matters
A deadlock bug in
flushPendingPromises()(awhileloop re-awaiting a promise tracked during flush) was caught only by code review, not by any test. The fix (snapshot-based single pass) is validated only by:aspire startwould timeout on deadlock, but these are slow, Docker-dependent, and can't test subtle error handlingA targeted TypeScript unit test could deterministically reproduce the deadlock scenario and prevent regressions.
Suggested approach
Add a test file (e.g.,
transport.test.ts) that:trackPromise+flushPendingPromiseswith controlled promise resolutionawaitAggregateErroris thrown when tracked promises rejectContext
Related PR: #15901 (Auto-resolve promises in TypeScript codegen)