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:
parent
2b8b4e5e9b
commit
3f1dacb8fc
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env npx tsx
|
#!/usr/bin/env npx tsx
|
||||||
import { spawn } from "node:child_process";
|
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 { tmpdir } from "node:os";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import express, { type Request, type Response } from "express";
|
import express, { type Request, type Response } from "express";
|
||||||
@ -32,7 +32,8 @@ function sendChatMessage(spaceId: string, text: string): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
proc.on("close", (code) => {
|
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) {
|
if (code !== 0) {
|
||||||
console.error(`[googlechat] Send failed with code ${code}`);
|
console.error(`[googlechat] Send failed with code ${code}`);
|
||||||
}
|
}
|
||||||
@ -40,7 +41,7 @@ function sendChatMessage(spaceId: string, text: string): void {
|
|||||||
|
|
||||||
proc.on("error", (err) => {
|
proc.on("error", (err) => {
|
||||||
console.error("[googlechat] Send error:", err.message);
|
console.error("[googlechat] Send error:", err.message);
|
||||||
try { unlinkSync(tmpFile); } catch {}
|
setTimeout(() => { try { unlinkSync(tmpFile); } catch {} }, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user