Skip to content

fix: resolve batched request resolver defects hanging consumer fibers#6139

Merged
tim-smart merged 2 commits intoEffect-TS:mainfrom
marbemac:mbm/fix-resolver-defect-hang
Mar 22, 2026
Merged

fix: resolve batched request resolver defects hanging consumer fibers#6139
tim-smart merged 2 commits intoEffect-TS:mainfrom
marbemac:mbm/fix-resolver-defect-hang

Conversation

@marbemac
Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

When a RequestResolver.makeBatched resolver dies with a defect (e.g. Effect.die), all consumer fibers waiting on requests from that batch hang forever. The request Deferreds are never completed, so Effect.request callers block indefinitely on deferredAwait.

Root Cause

In invokeWithInterrupt (fiberRuntime.ts), the cleanup logic that completes uncompleted request entries with exitInterrupt was chained via core.flatMap (OP_ON_SUCCESS), which only runs on success. When the daemon fiber running the resolver fails, the cleanup is skipped entirely.

Fix

Replaced core.flatMap with ensuring so the cleanup runs on all exit types (success, failure, and interruption). This is consistent with how ensuring is already used elsewhere in the fiber runtime (e.g. acquireRelease, addFinalizer).

Signed-off-by: Marc MacLeod <marbemac+gh@gmail.com>
@marbemac marbemac requested a review from mikearnaldi as a code owner March 22, 2026 00:05
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 22, 2026

🦋 Changeset detected

Latest commit: 7693751

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 36 packages
Name Type
effect Patch
@effect/cli Patch
@effect/cluster Patch
@effect/experimental Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/platform Patch
@effect/printer-ansi Patch
@effect/printer Patch
@effect/rpc Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-drizzle Patch
@effect/sql-kysely Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/sql Patch
@effect/typeclass Patch
@effect/vitest Patch
@effect/workflow Patch
@effect/ai Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-google Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch

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

@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Mar 22, 2026
@tim-smart tim-smart enabled auto-merge (squash) March 22, 2026 21:56
Signed-off-by: Marc MacLeod <marbemac+gh@gmail.com>
auto-merge was automatically disabled March 22, 2026 22:07

Head branch was pushed to by a user without write access

@tim-smart tim-smart enabled auto-merge (squash) March 22, 2026 22:07
@tim-smart tim-smart merged commit f99048e into Effect-TS:main Mar 22, 2026
11 checks passed
@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Done in PR Backlog Mar 22, 2026
@github-actions github-actions bot mentioned this pull request Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants