{"record":{"id":"dda16533670f07d6","repo":"paperclipai/paperclip","slug":"run-log-tail-tick-failed-exit-result-exitcode","errorCode":null,"errorMessage":"Run log tail tick failed (exit ${result.exitCode ?? \"null\"}${result.timedOut ? \", timed out\" : \"}).","messagePattern":"Run log tail tick failed \\(exit (.+?)(.+?)\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/adapter-utils/src/sandbox-run-log-stream.ts","lineNumber":177,"sourceCode":"    async function emitBytes(state: TailStreamState, bytes: Buffer): Promise<void> {\n      if (bytes.length === 0) return;\n      state.offset += bytes.length;\n      const text = state.decoder.write(bytes);\n      if (text.length > 0 && sink) {\n        await sink(state.stream, text);\n      }\n    }\n\n    async function tick(): Promise<void> {\n      const result = await options.runner.execute({\n        command: shellCommand,\n        args: shellCommandArgs(buildTickScript()),\n        cwd: options.remoteCwd,\n        env: { [SANDBOX_EXEC_CHANNEL_ENV]: SANDBOX_EXEC_CHANNEL_BRIDGE },\n        timeoutMs: tickTimeoutMs,\n      });\n      if (result.timedOut || (result.exitCode ?? 1) !== 0) {\n        throw new Error(\n          `Run log tail tick failed (exit ${result.exitCode ?? \"null\"}${result.timedOut ? \", timed out\" : \"\"}).`,\n        );\n      }\n      const sections = parseTickOutput(result.stdout);\n      if (!sections) {\n        throw new Error(\"Run log tail tick returned unparseable output.\");\n      }\n      await emitBytes(streams[0], sections.stdout);\n      await emitBytes(streams[1], sections.stderr);\n    }\n\n    async function loop(): Promise<void> {\n      let consecutiveFailures = 0;\n      while (!stopped) {\n        await sleep(pollIntervalMs);\n        if (stopped) break;\n        try {\n          await tick();","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/adapter-utils/src/sandbox-run-log-stream.ts#L159-L195","documentation":"Thrown by the run-log tail poller's tick() when the remote tail command exited non-zero or timed out. Each tick runs a sh script that tails the agent's stdout/stderr log files in base64 chunks; a non-zero exit (or timeout) means the remote shell, the bridge exec channel, or the log files are unavailable. The surrounding loop tolerates a few consecutive failures (maxConsecutiveFailures) before giving up.","triggerScenarios":"streamRunLog called while the remote log files are missing/unreadable, the bridge exec channel is saturated or down, tickTimeoutMs is too short for the tail+base64 command, or the sandbox host is unreachable. Each tick that fails increments consecutiveFailures.","commonSituations":"tickTimeoutMs set lower than the time to base64 a large log chunk; remote filesystem where the log file lives was unmounted; bridge process crashed mid-run; SSH/exec channel latency spikes; permission change on the log dir.","solutions":["Raise tickTimeoutMs and confirm it exceeds worst-case tail+base64 latency for the largest expected chunk (maxChunkBytes).","Check the bridge process (pid from bridge directories) is alive and the exec channel returns quickly.","Verify the log files referenced by stream states exist and are readable by the remote user.","Tune maxConsecutiveFailures/pollIntervalMs so transient exec hiccups do not abort the stream."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (tickTimeoutMs < maxChunkBytes /* approx base64 cost */) {\n  throw new Error('tickTimeoutMs too small for maxChunkBytes; raise it');\n}","typeGuard":null,"tryCatchPattern":"// The loop already tolerates consecutiveFailures; surface only if it gives up.\n// In your own code wrapping streamRunLog:\ntry {\n  await streamRunLog(opts);\n} catch (err) {\n  logger.warn('run log stream terminated', { message: (err as Error).message });\n}","preventionTips":["Size tickTimeoutMs above worst-case tail+base64 latency.","Keep the bridge exec channel responsive; monitor its pid.","Ensure log files are readable by the remote user throughout the run."],"tags":["sandbox","log-stream","timeout","remote-execution","polling"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}