Skip to main content
← Back to list
01Issue
BugShippedSwamp CLIPublic
Assigneeshammz

Relationships

#2616 withGeneratorSpan does not forward return() to the wrapped generator, so its finally blocks are skipped on early exit

Opened by hammz · 9/28/2026· Shipped 9/29/2026

Problem

withGeneratorSpan in src/infrastructure/tracing/tracer.ts drives the wrapped generator with a manual iterator.next() loop so it can bind each step to the span context. When the consumer stops early (a break out of for await, or an explicit .return()), the outer generator's finally runs and ends the span, but it never calls return() on the inner iterator. The inner generator stays suspended at its yield, so its own finally blocks never run.

It wraps libswamp generators, including swamp.workflow.run.command, so any cleanup those generators (or generators they delegate to) keep in finally — releasing sinks, locks, affinities, ending child spans — is skipped when a consumer abandons the stream through the wrapper.

Expected

On early exit, withGeneratorSpan forwards return() to the inner iterator (inside the span context) when the inner has not already finished, as bindGeneratorToSpan does (added in swamp-club#2589).

Notes

Found during the adversarial review of swamp-club#2589 (ADV-3). The bindGeneratorToSpan tests in tracer_test.ts show the shape of a regression test: break mid-iteration and assert the inner finally ran exactly once.

02Bog Flow
✓OPEN✓TRIAGED✓IN PROGRESS✓SHIPPED+ 1 MOREASSIGNED+ 2 MOREREVIEW+ 10 MOREPR_MERGED+ 2 MORESESSION_SUMMARIZED

Shipped

9/29/2026, 7:06:40 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
hammz assigned hammz9/29/2026, 6:28:49 PM

Sign in to post a ripple.