Skip to content

Improve drain semantics via STM in DrainableWorker#1474

Merged
juliusmarminge merged 9 commits intopingdotgg:mainfrom
IMax153:chore/improve-drainable-worker
Mar 28, 2026
Merged

Improve drain semantics via STM in DrainableWorker#1474
juliusmarminge merged 9 commits intopingdotgg:mainfrom
IMax153:chore/improve-drainable-worker

Conversation

@IMax153
Copy link
Copy Markdown
Contributor

@IMax153 IMax153 commented Mar 27, 2026

What Changed

Why

UI Changes

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk
Moderate risk: upgrades core Effect packages and changes concurrency/runtime execution patterns (runPromiseWith/runForkWith) plus STM-based worker semantics, which could affect scheduling and error handling at runtime.

Overview
Refactors DrainableWorker to deterministic STM semantics. Replaces Queue/Ref/Deferred tracking with TxQueue + TxRef, and implements drain() as an STM transaction that retries until the queue is empty and no items are in flight.

Upgrades Effect ecosystem deps to 4.0.0-beta.42 and aligns runtime execution patterns. Updates server code and tests to capture services and use Effect.runPromiseWith/Effect.runForkWith (e.g. wsServer, ClaudeAdapter, GitCore tests), and adjusts CLI tests to swallow parse-failure errors. Also improves NodeSqliteClient error reporting by classifying SQLite errors via classifySqliteError with operation context.

Written by Cursor Bugbot for commit a655ecf. This will update automatically on new commits. Configure here.

Note

Rewrite DrainableWorker drain semantics using STM with TxQueue and TxRef

  • Replaces Queue/Deferred/Ref in DrainableWorker.ts with TxQueue and TxRef to make drain semantics transactionally correct.
  • drain() now retries atomically via STM until both the queue is empty and the in-flight counter reaches zero, eliminating races between enqueue and drain completion.
  • Queue lifecycle is now managed with Effect.acquireRelease for safe cleanup.
  • Upgrades effect and related @effect/* packages to 4.0.0-beta.42 and fixes child effects across ClaudeAdapter, wsServer, and tests to use runForkWith/runPromiseWith with captured service environments instead of unscoped Effect.runFork/Effect.runPromise.

Macroscope summarized a655ecf.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eff8cb7e-0c3d-41ef-b11b-761fb438f80e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 27, 2026
@juliusmarminge juliusmarminge merged commit e08cea3 into pingdotgg:main Mar 28, 2026
10 of 11 checks passed
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

const unsubscribeTerminalEvents = yield* terminalManager.subscribe(
(event) => void Effect.runPromise(pushBus.publishAll(WS_CHANNELS.terminalEvent, event)),
const unsubscribeTerminalEvents = yield* terminalManager.subscribe((event) =>
runPromise(pushBus.publishAll(WS_CHANNELS.terminalEvent, event)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing void in terminal subscribe callback returns Promise

Low Severity

The terminal subscribe callback previously used void Effect.runPromise(...) to explicitly discard the returned Promise (fire-and-forget pattern). The refactored code drops the void, so the callback now returns a Promise<void> instead of undefined. The listener type is (event: TerminalEvent) => void, and while the EventEmitter ignores return values, this is inconsistent with the HTTP handler on line 437 which correctly keeps void runPromise(...). The missing void appears unintentional.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants