pi-ext
bugabingas pi extensions
owned by bugabinga
fix(os-notifier): hard-kill timed out native commands
e3d6b65dd511000c96bc6877f62c1a954262d6f0
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (2)
extensions/os-notifier/__tests__/harness.test.ts
Modified 92 92 await deliverNative(
94 94 command:
process.
execPath,
95 - args: [
"-e",
"setInterval(() => {}, 1000)"],
97 + "process.on('SIGTERM', () => {}); setInterval(() => {}, 1000)",
200 203 const notification
= agentDoneNotification(
203 - { role:
"user", content:
`prompt\u0000${"x".repeat(100)}` },
206 + { role:
"user", content:
`prompt\u0000\u009d${"x".repeat(100)}` },
205 208 role:
"assistant",
206 209 stopReason:
"error",
213 216 expect(notification.
title).
toBe(
"Pi failed");
214 217 expect(notification.severity).
toBe(
"error");
215 218 expect(notification.message).not.
toContain(
"\u0000");
219 + expect(notification.message).not.
toContain(
"\u009d");
216 220 expect(notification.message.
match(
/\n/gu)).
toHaveLength(
1);
217 221 expect(notification.message.
length).
toBeLessThan(
240);
218 222 expect(notification.message).
toContain(
"…");
extensions/os-notifier/index.ts
Modified 28 28 function compact(value
: unknown, limit
= Number.POSITIVE_INFINITY)
: string {
29 29 if (
typeof value
!== "string")
return "";
30 - const text
= value.
replace(
/[\x00-\x1f\x7f]+/g,
" ").
trim();
30 + const text
= value.
replace(
/[\x00-\x1f\x7f-\x9f]+/g,
" ").
trim();
31 31 if (text.
length <= limit)
return text;
32 32 return `${text.slice(0, limit).trimEnd()}…`;
310 - { env: command.env, timeout: timeoutMs },
310 + { env: command.env, timeout: timeoutMs, killSignal:
"SIGKILL" },
312 312 if (error)
useFallback();
313 313 else resolveDelivery();