Fix txPubSub subscriber release interrupts after hub shutdown - #7117
Conversation
🦋 Changeset detectedLatest commit: cfa0903 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
This PR adds a focused regression test, but the implementation fix described in the title and commit message is not present in the diff. CI will fail until TxQueue.shutdown is made tolerant of repeated interruption.
Reviewed changes
- Added one regression test in
packages/effect/test/TxPubSub.test.tsthat reproducesScope.closeexiting with interruption when a TxPubSub subscriber is released after hub shutdown.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the delta since the prior Pullfrog review.
- Added a changeset describing the
TxQueue.shutdownidempotency fix. - Changed
TxQueue.shutdownto useEffect.ignoreCause(clear(self))instead ofEffect.ignore(clear(self)), so repeated shutdown after an interruption cause no longer propagates that interruption through the finalizer. - The regression test added in the prior commit now passes:
Scope.closeon a subscriber scope succeeds after hub shutdown.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
TxPubSub.shutdown first calls TxQueue.shutdown on the subscriber. Its scope finalizer later calls releaseSubscriber, which calls TxQueue.shutdown again. clear observes the queue's interrupt Done cause; Effect.ignore does not recover interruption, so the finalizer and Scope.close exit with interruption. The minimal public sequence TxQueue.shutdown(queue) twice likewise yields Success(true) then an interrupt Exit rather than a boolean result.
Important
This PR includes the focused regression test and the implementation fix in
TxQueue.shutdown.TxPubSub subscriber release interrupts after hub shutdown
Module:
packages/effect/src/TxPubSub.tsAudit ID:
relsem-txpubsub-release-after-shutdownSeverity / confidence: medium / high
What happens
TxPubSub.shutdown first calls TxQueue.shutdown on the subscriber. Its scope finalizer later calls releaseSubscriber, which calls TxQueue.shutdown again. clear observes the queue's interrupt Done cause; Effect.ignore does not recover interruption, so the finalizer and Scope.close exit with interruption. The minimal public sequence TxQueue.shutdown(queue) twice likewise yields Success(true) then an interrupt Exit rather than a boolean result.
Why it happens
TxQueue.shutdown attempts to tolerate clear failure with Effect.ignore, but clear can fail by interruption when the queue is already interrupt-completed. Effect.ignore handles the typed failure channel, not the full interruption cause, so repeated shutdown is not total and TxPubSub's release finalizer inherits that interruption.
Expected behavior
A scoped TxPubSub subscription release must unregister and shut down its queue without turning ordinary scope closure into interruption, including when hub shutdown already terminated that queue.
Relevant implementation
These links and excerpts are pinned to audit base
b206fa5d7655c1634c9993410a9203f6616a5ca2.packages/effect/src/TxPubSub.ts:582View problematic code at
packages/effect/src/TxPubSub.ts:582View exact lines on GitHub
Reproduction
Validation: The reproduction failed before the implementation change and passes after it.
Implementation
TxQueue.shutdownnow ignores the full cause fromclearbefore interrupting the queue, making repeated shutdown safe when the queue is already interrupted.The focused regression, full
effecttest project, repository lint, and type checks all pass.Audit provenance
b206fa5d7655c1634c9993410a9203f6616a5ca2b206fa5d7655c1634c9993410a9203f6616a5ca2relsem-txpubsub-release-after-shutdownTxQueue.shutdownCloses EFF-552