From 3f1dacb8fc6eb0489557297379fcc663e7336042 Mon Sep 17 00:00:00 2001 From: Justin Massa Date: Sun, 18 Jan 2026 20:16:31 -0600 Subject: [PATCH] chore: cleanup unused import, add safety delay for temp file cleanup - Remove unused readFileSync import - Add 100ms delay before deleting temp files to ensure Python has read them Co-Authored-By: Claude Opus 4.5 --- src/googlechat/run-webhook.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/googlechat/run-webhook.ts b/src/googlechat/run-webhook.ts index 7f8f01736..452ad8ba8 100644 --- a/src/googlechat/run-webhook.ts +++ b/src/googlechat/run-webhook.ts @@ -1,6 +1,6 @@ #!/usr/bin/env npx tsx import { spawn } from "node:child_process"; -import { writeFileSync, unlinkSync, readFileSync } from "node:fs"; +import { writeFileSync, unlinkSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import express, { type Request, type Response } from "express"; @@ -32,7 +32,8 @@ function sendChatMessage(spaceId: string, text: string): void { }); proc.on("close", (code) => { - try { unlinkSync(tmpFile); } catch {} + // Small delay ensures Python has finished reading the file + setTimeout(() => { try { unlinkSync(tmpFile); } catch {} }, 100); if (code !== 0) { console.error(`[googlechat] Send failed with code ${code}`); } @@ -40,7 +41,7 @@ function sendChatMessage(spaceId: string, text: string): void { proc.on("error", (err) => { console.error("[googlechat] Send error:", err.message); - try { unlinkSync(tmpFile); } catch {} + setTimeout(() => { try { unlinkSync(tmpFile); } catch {} }, 100); }); } catch (e) {