fix(server): isolate provider command lanes by thread #7071
Closedclintebbesen(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/7071/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- packages/shared/src/DrainableWorker.ts line 78Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -30,0 +50,21 @@50+ }51+ }52+ });53+54+ const enqueue = (item: A): Effect.Effect<void> =>55+ Effect.gen(function* () {56+ const key = keyOf(item);57+ const existing = entries.get(key);58+ if (existing !== undefined) {59+ existing.version += 1;60+ yield* existing.worker.enqueue(item);61+ return;62+ }63+ const worker = yield* makeDrainableWorker(process).pipe(64+ Effect.provide(context),65+ Scope.provide(scope),66+ );67+ const entry: Entry = { worker, version: 1 };68+ entries.set(key, entry);69+ yield* worker.enqueue(item);70+ yield* removeWhenIdle(key, entry).pipe(Effect.forkIn(scope));
- @@ -30,0 +45,21 @@45+ const entries = new Map<K, Entry>();46+ const processInParentScope = (item: A) =>47+ process(item).pipe(Effect.provide(context), Scope.provide(scope));48+49+ const removeWhenIdle = (key: K, entry: Entry) =>50+ Effect.gen(function* () {51+ while (entries.get(key) === entry) {52+ const observedVersion = entry.version;53+ yield* entry.worker.drain;54+ if (entry.version === observedVersion && entries.get(key) === entry) {55+ entries.delete(key);56+ yield* Scope.close(entry.scope, Exit.void);57+ return;58+ }59+ }60+ });61+62+ const enqueue = (item: A): Effect.Effect<void> =>63+ Effect.gen(function* () {64+ const key = keyOf(item);65+ const existing = entries.get(key);
shivamhwp(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
c6db509b-8e09-4829-b3fc-91dfc1be273cYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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