The best way to control Claude Code, Codex and more from any computer or phone
fix(server): fall back when checkpoint fsync is unsupported (#14411)
Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
mohammed shazeb committed
Oct 19, 2026 at 10:42 UTC
67e05acf817e536d18adaf2125ded8962ea5fbce
3 files changed
+135
-9
apps/server/src/vcs/GitVcsDriver.ts
+1
@@ -784,6 +784,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
784
// an unclean restart can leave 0-byte files under refs/t3/** that break every
785
// later fetch and push. Checkpoint writes flush before they are published;
786
// macOS defaults to writeout-only, which does not reach the disk either.
787
+ // On macOS, VcsProcess retries unsupported full flushes with plain fsync.
788
const durableWrite = [
789
"-c",
790
"core.fsync=objects,reference",
apps/server/src/vcs/VcsProcess.test.ts
+92
@@ -97,6 +97,98 @@ describe("VcsProcess.run", () => {
97
}),
98
);
99
100
+ it.effect.each([
101
+ {
102
+ stderr: "fatal: fsync error on '.git/objects/a5/tmp_obj_Pseg66': Operation not supported",
103
+ fsyncMethods: ["fsync", "writeout-only"],
104
+ },
105
+ {
106
+ stderr:
107
+ "fatal: update_ref failed for ref 'refs/t3/checkpoints/x': cannot update ref 'refs/t3/checkpoints/x': couldn't write '/Volumes/share/.git/refs/t3/checkpoints/x.lock'",
108
+ fsyncMethods: ["fsync", "writeout-only"],
109
+ },
110
+ { stderr: "fatal: Operation not supported", fsyncMethods: ["fsync"] },
111
+ {
112
+ stderr:
113
+ "fatal: update_ref failed for ref 'refs/t3/checkpoints/x': cannot update ref 'refs/t3/checkpoints/x': couldn't write '/Volumes/share/.git/refs/t3/checkpoints/x.lock': Input/output error",
114
+ fsyncMethods: ["fsync"],
115
+ },
116
+ {
117
+ stderr: "fatal: fsync error on '.git/objects/a5/tmp_obj_Pseg66': Operation not supported",
118
+ fsyncMethods: ["fsync", "writeout-only"],
119
+ fallbackFails: true,
120
+ },
121
+ {
122
+ platform: "linux",
123
+ stderr: "fatal: fsync error on '.git/objects/a5/tmp_obj_Pseg66': Operation not supported",
124
+ fsyncMethods: ["fsync"],
125
+ },
126
+ {
127
+ operation: baseInput.operation,
128
+ stderr: "fatal: fsync error on '.git/objects/a5/tmp_obj_Pseg66': Operation not supported",
129
+ fsyncMethods: ["fsync"],
130
+ },
131
+ ] as const)(
132
+ "falls back to writeout-only only for unsupported fsync on macOS: $stderr",
133
+ ({ stderr, fsyncMethods, ...scenario }) =>
134
+ Effect.gen(function* () {
135
+ const seen: Array<ReadonlyArray<string>> = [];
136
+ const service = yield* VcsProcess.make.pipe(
137
+ Effect.provideService(
138
+ HostProcess.Platform,
139
+ "platform" in scenario ? scenario.platform : "darwin",
140
+ ),
141
+ Effect.provideService(ProcessRunner.ProcessRunner, {
142
+ run: (input) =>
143
+ Effect.sync(() => {
144
+ seen.push(input.args);
145
+ const failed =
146
+ input.args.includes("core.fsyncMethod=fsync") ||
147
+ ("fallbackFails" in scenario && scenario.fallbackFails);
148
+ return {
149
+ stdout: "",
150
+ stderr: failed ? stderr : "",
151
+ code: ChildProcessSpawner.ExitCode(failed ? 128 : 0),
152
+ timedOut: false,
153
+ stdoutTruncated: false,
154
+ stderrTruncated: false,
155
+ stdoutInvalidUtf8: false,
156
+ stderrInvalidUtf8: false,
157
+ };
158
+ }),
159
+ }),
160
+ );
161
+ const exit = yield* service
162
+ .run({
163
+ ...baseInput,
164
+ operation:
165
+ "operation" in scenario
166
+ ? scenario.operation
167
+ : VcsProcess.CHECKPOINT_CAPTURE_OPERATION,
168
+ args: ["-c", "core.fsync=objects,reference", "-c", "core.fsyncMethod=fsync", "add"],
169
+ })
170
+ .pipe(Effect.exit);
171
+ expect(seen).toEqual(
172
+ fsyncMethods.map((method) => [
173
+ "-c",
174
+ "core.fsync=objects,reference",
175
+ "-c",
176
+ `core.fsyncMethod=${method}`,
177
+ "add",
178
+ ]),
179
+ );
180
+ expect(Exit.isSuccess(exit)).toBe(
181
+ fsyncMethods.length === 2 && !("fallbackFails" in scenario && scenario.fallbackFails),
182
+ );
183
+ if (Exit.isFailure(exit)) {
184
+ expect(Cause.findErrorOption(exit.cause)).toMatchObject({
185
+ _tag: "Some",
186
+ value: { _tag: "VcsProcessExitError", exitCode: 128 },
187
+ });
188
+ }
189
+ }),
190
+ );
191
+
192
it.effect.each(["timeout", "spawn"] as const)(
193
"checkpoint commands do not retry %s failures",
194
(kind) =>
apps/server/src/vcs/VcsProcess.ts
+42
-9
@@ -9,6 +9,7 @@ import { ChildProcessSpawner } from "effect/process";
9
10
import {
11
type VcsError,
12
+ type VcsProcessErrorContext,
13
VcsProcessExitError,
14
type VcsProcessExitFailureKind,
15
VcsProcessMissingExitCodeError,
@@ -162,21 +163,24 @@ const isTransientGitExit = (stderr: string) =>
163
/unable to create [^\n]*\.lock['"]?: file exists/i.test(stderr) ||
164
/(?:unable to stat|lstat\(|error: open\()[^\n]+: no such file or directory/i.test(stderr);
165
166
+// On macOS, Git's fsync uses F_FULLFSYNC; writeout-only still uses fsync(2).
167
+// Network mounts can reject F_FULLFSYNC. Ref writes omit errno, so retry their
168
+// bare write error too; explicit unrelated errors remain failures.
169
+// Linux writeout-only only starts writeback, so it must not use this fallback.
170
+const FULL_FSYNC_ARG = "core.fsyncMethod=fsync";
171
+const WRITEOUT_ONLY_FSYNC_ARG = "core.fsyncMethod=writeout-only";
172
+const canRetryFullFsync = (stderr: string) =>
173
+ /fsync error on [^\r\n]+: operation not supported\r?$/im.test(stderr) ||
174
+ /cannot update ref [^\r\n]+: couldn't write '[^\r\n]+\.lock'\r?$/im.test(stderr);
175
+
176
export const make = Effect.gen(function* () {
177
const processRunner = yield* ProcessRunner.ProcessRunner;
178
const hostPlatform = yield* HostProcess.Platform;
179
const vcsProcesses = yield* Semaphore.make(VCS_PROCESS_CONCURRENCY);
180
const githubProcesses = yield* Semaphore.make(GITHUB_PROCESS_CONCURRENCY);
181
171
- const runUnbounded = Effect.fn("VcsProcess.runUnbounded")(function* (input: VcsProcessInput) {
172
- const baseError = {
173
- operation: input.operation,
174
- command: input.command,
175
- cwd: input.cwd,
176
- argumentCount: input.args.length,
177
- };
178
-
179
- const result = yield* processRunner
182
+ const spawn = (input: VcsProcessInput, baseError: VcsProcessErrorContext) =>
183
+ processRunner
184
.run({
185
command: input.command,
186
args: input.args,
@@ -224,6 +228,35 @@ export const make = Effect.gen(function* () {
228
),
229
);
230
231
+ const runUnbounded = Effect.fn("VcsProcess.runUnbounded")(function* (input: VcsProcessInput) {
232
+ const baseError = {
233
+ operation: input.operation,
234
+ command: input.command,
235
+ cwd: input.cwd,
236
+ argumentCount: input.args.length,
237
+ };
238
+
239
+ let result = yield* spawn(input, baseError);
240
+
241
+ if (
242
+ hostPlatform === "darwin" &&
243
+ input.operation === CHECKPOINT_CAPTURE_OPERATION &&
244
+ !input.allowNonZeroExit &&
245
+ result.code !== null &&
246
+ result.code !== 0 &&
247
+ input.command === "git" &&
248
+ input.args.includes(FULL_FSYNC_ARG) &&
249
+ canRetryFullFsync(result.stderr)
250
+ ) {
251
+ result = yield* spawn(
252
+ {
253
+ ...input,
254
+ args: input.args.map((arg) => (arg === FULL_FSYNC_ARG ? WRITEOUT_ONLY_FSYNC_ARG : arg)),
255
+ },
256
+ baseError,
257
+ );
258
+ }
259
+
260
if (result.code === null) {
261
return yield* new VcsProcessMissingExitCodeError(baseError);
262
}