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 <noreply@anthropic.com>
This commit is contained in:
Justin Massa 2026-01-18 20:16:31 -06:00
parent 2b8b4e5e9b
commit 3f1dacb8fc

View File

@ -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) {