From e6d7e449b0e24ff89b61d58a6021fff5012197dc Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Tue, 23 Jun 2026 09:46:56 +0800 Subject: [PATCH] fix(web-probe): write observe runner through file payload (#729) Co-authored-by: Codex --- scripts/src/hwlab-node-impl.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/src/hwlab-node-impl.ts b/scripts/src/hwlab-node-impl.ts index bd590482..e3fae2d7 100644 --- a/scripts/src/hwlab-node-impl.ts +++ b/scripts/src/hwlab-node-impl.ts @@ -7767,6 +7767,7 @@ function runNodeWebProbeObserveStart( const defaultStateDir = `.state/web-observe/${safeWebObserveSegment(options.node)}/${safeWebObserveSegment(options.lane)}/${day.slice(0, 4)}/${day.slice(4, 6)}/${day.slice(6, 8)}/${timestamp}_${safeWebObserveTargetSegment(options.targetPath)}_${jobId}`; const stateDir = options.stateDir ?? defaultStateDir; const runnerB64 = Buffer.from(nodeWebObserveRunnerSource(), "utf8").toString("base64"); + const runnerB64Body = runnerB64.match(/.{1,76}/gu)?.join("\n") ?? runnerB64; const webProbeProxy = nodeWebProbeHostProxyEnv(spec); const alertThresholds = nodeWebProbeAlertThresholds(spec); const runnerEnvAssignments = [ @@ -7791,7 +7792,12 @@ function runNodeWebProbeObserveStart( "mkdir -p \"$state_dir\"", "chmod 700 \"$state_dir\"", "runner=\"$state_dir/observer-runner.mjs\"", - `node -e "require('fs').writeFileSync(process.argv[1], Buffer.from(process.argv[2], 'base64'))" "$runner" ${shellQuote(runnerB64)}`, + "runner_b64=\"$state_dir/observer-runner.mjs.b64\"", + "cat >\"$runner_b64\" <<'UNIDESK_WEB_OBSERVE_RUNNER_B64'", + runnerB64Body, + "UNIDESK_WEB_OBSERVE_RUNNER_B64", + "node -e \"const fs=require('fs'); fs.writeFileSync(process.argv[1], Buffer.from(fs.readFileSync(process.argv[2], 'utf8').replace(/\\s+/g, ''), 'base64'))\" \"$runner\" \"$runner_b64\"", + "rm -f \"$runner_b64\"", "chmod 700 \"$runner\"", `if command -v setsid >/dev/null 2>&1; then setsid env ${runnerEnvAssignments} node "$runner" >"$state_dir/stdout.log" 2>"$state_dir/stderr.log" "$state_dir/stdout.log" 2>"$state_dir/stderr.log"