Skip to content

Commit 8da495a

Browse files
authored
Improve checkpoint reliability and cleanup of temp files (#1367)
* improve cleanup reliability * improve logging * bye-bye execa * fix for trailing newlines * prettier errors * trim args and log output by default * fix archive cleanup * prevent potential memleak * more cleanup debug logs * ignore abort during cleanup * rename checkpoint dir env var and move to helper * add global never throw override * add tmp cleaner * also clean up checkpoint dir by default * split by any whitespace, not just tabs * only create tmp cleaner if paths to clean
1 parent 69ec68e commit 8da495a

File tree

8 files changed

+561
-140
lines changed

8 files changed

+561
-140
lines changed

apps/coordinator/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
"license": "MIT",
1818
"dependencies": {
1919
"@trigger.dev/core": "workspace:*",
20-
"execa": "^8.0.1",
2120
"nanoid": "^5.0.6",
2221
"prom-client": "^15.1.0",
23-
"socket.io": "4.7.4"
22+
"socket.io": "4.7.4",
23+
"tinyexec": "^0.3.0"
2424
},
2525
"devDependencies": {
2626
"@types/node": "^18",

apps/coordinator/src/chaosMonkey.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { Execa$ } from "execa";
21
import { setTimeout as timeout } from "node:timers/promises";
32

43
class ChaosMonkeyError extends Error {
@@ -35,11 +34,9 @@ export class ChaosMonkey {
3534
}
3635

3736
async call({
38-
$,
3937
throwErrors = !this.disableErrors,
4038
addDelays = !this.disableDelays,
4139
}: {
42-
$?: Execa$<string>;
4340
throwErrors?: boolean;
4441
addDelays?: boolean;
4542
} = {}) {
@@ -60,23 +57,15 @@ export class ChaosMonkey {
6057
chaosEvents.push(async () => {
6158
console.log("🍌 Chaos monkey: Add delay");
6259

63-
if ($) {
64-
await $`sleep ${this.delayInSeconds}`;
65-
} else {
66-
await timeout(this.delayInSeconds * 1000);
67-
}
60+
await timeout(this.delayInSeconds * 1000);
6861
});
6962
}
7063

7164
if (throwErrors) {
7265
chaosEvents.push(async () => {
7366
console.log("🍌 Chaos monkey: Throw error");
7467

75-
if ($) {
76-
await $`false`;
77-
} else {
78-
throw new ChaosMonkey.Error("🍌 Chaos monkey: Throw error");
79-
}
68+
throw new ChaosMonkey.Error("🍌 Chaos monkey: Throw error");
8069
});
8170
}
8271

0 commit comments

Comments
 (0)