fix: use os.tmpdir fallback paths for temp files (#14985)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 347c689407037a05be0717209660076c6a07d0ec
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
Gustavo Madeira Santana
2026-02-12 16:08:41 -05:00
committed by GitHub
parent 282fb9ad52
commit afbce73570
5 changed files with 19 additions and 6 deletions
+1
View File
@@ -29,6 +29,7 @@ Docs: https://docs.openclaw.ai
- Cron: isolate scheduler errors so one bad job does not break all jobs. (#14385) Thanks @MarvinDontPanic. - Cron: isolate scheduler errors so one bad job does not break all jobs. (#14385) Thanks @MarvinDontPanic.
- Cron: prevent one-shot `at` jobs from re-firing on restart after skipped/errored runs. (#13878) Thanks @lailoo. - Cron: prevent one-shot `at` jobs from re-firing on restart after skipped/errored runs. (#13878) Thanks @lailoo.
- Heartbeat: prevent scheduler stalls on unexpected run errors and avoid immediate rerun loops after `requests-in-flight` skips. (#14901) Thanks @joeykrug. - Heartbeat: prevent scheduler stalls on unexpected run errors and avoid immediate rerun loops after `requests-in-flight` skips. (#14901) Thanks @joeykrug.
- Logging/Browser: fall back to `os.tmpdir()/openclaw` for default log, browser trace, and browser download temp paths when `/tmp/openclaw` is unavailable.
- WhatsApp: convert Markdown bold/strikethrough to WhatsApp formatting. (#14285) Thanks @Raikan10. - WhatsApp: convert Markdown bold/strikethrough to WhatsApp formatting. (#14285) Thanks @Raikan10.
- WhatsApp: allow media-only sends and normalize leading blank payloads. (#14408) Thanks @karimnaguib. - WhatsApp: allow media-only sends and normalize leading blank payloads. (#14408) Thanks @karimnaguib.
- WhatsApp: default MIME type for voice messages when Baileys omits it. (#14444) Thanks @mcaxtr. - WhatsApp: default MIME type for voice messages when Baileys omits it. (#14444) Thanks @mcaxtr.
+2 -1
View File
@@ -1,6 +1,7 @@
import type { Page } from "playwright-core"; import type { Page } from "playwright-core";
import crypto from "node:crypto"; import crypto from "node:crypto";
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path"; import path from "node:path";
import { import {
ensurePageState, ensurePageState,
@@ -20,7 +21,7 @@ import {
function buildTempDownloadPath(fileName: string): string { function buildTempDownloadPath(fileName: string): string {
const id = crypto.randomUUID(); const id = crypto.randomUUID();
const safeName = fileName.trim() ? fileName.trim() : "download.bin"; const safeName = fileName.trim() ? fileName.trim() : "download.bin";
return path.join("/tmp/openclaw/downloads", `${id}-${safeName}`); return path.join(os.tmpdir(), "openclaw", "downloads", `${id}-${safeName}`);
} }
function createPageDownloadWaiter(page: Page, timeoutMs: number) { function createPageDownloadWaiter(page: Page, timeoutMs: number) {
+2 -1
View File
@@ -1,5 +1,6 @@
import crypto from "node:crypto"; import crypto from "node:crypto";
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path"; import path from "node:path";
import type { BrowserRouteContext } from "../server-context.js"; import type { BrowserRouteContext } from "../server-context.js";
import type { BrowserRouteRegistrar } from "./types.js"; import type { BrowserRouteRegistrar } from "./types.js";
@@ -131,7 +132,7 @@ export function registerBrowserAgentDebugRoutes(
return; return;
} }
const id = crypto.randomUUID(); const id = crypto.randomUUID();
const dir = "/tmp/openclaw"; const dir = path.join(os.tmpdir(), "openclaw");
await fs.mkdir(dir, { recursive: true }); await fs.mkdir(dir, { recursive: true });
const tracePath = out.trim() || path.join(dir, `browser-trace-${id}.zip`); const tracePath = out.trim() || path.join(dir, `browser-trace-${id}.zip`);
await pw.traceStopViaPlaywright({ await pw.traceStopViaPlaywright({
@@ -57,7 +57,7 @@ export function registerBrowserFilesAndDownloadsCommands(
browser browser
.command("waitfordownload") .command("waitfordownload")
.description("Wait for the next download (and save it)") .description("Wait for the next download (and save it)")
.argument("[path]", "Save path (default: /tmp/openclaw/downloads/...)") .argument("[path]", "Save path (default: os.tmpdir()/openclaw/downloads/...)")
.option("--target-id <id>", "CDP target id (or unique prefix)") .option("--target-id <id>", "CDP target id (or unique prefix)")
.option( .option(
"--timeout-ms <ms>", "--timeout-ms <ms>",
+13 -3
View File
@@ -1,5 +1,6 @@
import fs from "node:fs"; import fs from "node:fs";
import { createRequire } from "node:module"; import { createRequire } from "node:module";
import os from "node:os";
import path from "node:path"; import path from "node:path";
import { Logger as TsLogger } from "tslog"; import { Logger as TsLogger } from "tslog";
import type { OpenClawConfig } from "../config/types.js"; import type { OpenClawConfig } from "../config/types.js";
@@ -8,9 +9,18 @@ import { readLoggingConfig } from "./config.js";
import { type LogLevel, levelToMinLevel, normalizeLogLevel } from "./levels.js"; import { type LogLevel, levelToMinLevel, normalizeLogLevel } from "./levels.js";
import { loggingState } from "./state.js"; import { loggingState } from "./state.js";
// Pin to /tmp so mac Debug UI and docs match; os.tmpdir() can be a per-user // Prefer /tmp/openclaw so macOS Debug UI and docs match, but fall back to
// randomized path on macOS which made the “Open log” button a no-op. // os.tmpdir() on platforms where /tmp is read-only (e.g. Termux/Android).
export const DEFAULT_LOG_DIR = "/tmp/openclaw"; function resolveDefaultLogDir(): string {
try {
fs.mkdirSync("/tmp/openclaw", { recursive: true });
return "/tmp/openclaw";
} catch {
return path.join(os.tmpdir(), "openclaw");
}
}
export const DEFAULT_LOG_DIR = resolveDefaultLogDir();
export const DEFAULT_LOG_FILE = path.join(DEFAULT_LOG_DIR, "openclaw.log"); // legacy single-file path export const DEFAULT_LOG_FILE = path.join(DEFAULT_LOG_DIR, "openclaw.log"); // legacy single-file path
const LOG_PREFIX = "openclaw"; const LOG_PREFIX = "openclaw";