fix: use forkDetach for background upstream refresh to prevent scope interruption
Effect.forkScoped ties the background fiber's lifetime to the enclosing scope. When wsServer wraps checkoutBranch in Effect.scoped, the scope closes immediately after checkout completes, interrupting the background git fetch. Switch to Effect.forkDetach so the background refresh runs independently, remove the now-unnecessary Scope.Scope requirement from checkoutBranch, and drop Effect.scoped from the WebSocket handler. Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
8105951682
commit
de7f50ec6b
3 files changed
+4
-4
No files matched your search
@@ -1161,7 +1161,7 @@ const makeGitCore = Effect.gen(function* () {
|
||||
});
|
||||
|
||||
// Refresh upstream refs in the background so checkout remains responsive.
|
||||
yield* Effect.forkScoped(
|
||||
yield* Effect.forkDetach(
|
||||
refreshCheckedOutBranchUpstream(input.cwd).pipe(Effect.catch(() => Effect.void)),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @module GitCore
|
||||
*/
|
||||
import { ServiceMap } from "effect";
|
||||
import type { Effect, Scope } from "effect";
|
||||
import type { Effect } from "effect";
|
||||
import type {
|
||||
GitCheckoutInput,
|
||||
GitCreateBranchInput,
|
||||
@@ -151,7 +151,7 @@ export interface GitCoreShape {
|
||||
*/
|
||||
readonly checkoutBranch: (
|
||||
input: GitCheckoutInput,
|
||||
) => Effect.Effect<void, GitCommandError, Scope.Scope>;
|
||||
) => Effect.Effect<void, GitCommandError>;
|
||||
|
||||
/**
|
||||
* Initialize a repository in the provided directory.
|
||||
|
||||
@@ -689,7 +689,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
|
||||
case WS_METHODS.gitCheckout: {
|
||||
const body = stripRequestTag(request.body);
|
||||
return yield* Effect.scoped(git.checkoutBranch(body));
|
||||
return yield* git.checkoutBranch(body);
|
||||
}
|
||||
|
||||
case WS_METHODS.gitInit: {
|
||||
|
||||
Reference in new issue
Block a user