@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 31 lines 939 Bytes
Raw
1 import * as Effect from "effect/Effect";
2 import * as Semaphore from "effect/Semaphore";
3
4 // Amplify throttles CreateApp account-wide and reports it as a
5 // BadRequestException. The resource and binding files all create an app while
6 // alchemy-test runs files concurrently in one process. Hold this lease from a
7 // file's root beforeAll through its root afterAll so those lifecycles cannot
8 // overlap.
9 const amplifyTestLock = Semaphore.makeUnsafe(1);
10
11 export const makeAmplifyTestLease = () => {
12 let held = false;
13
14 return {
15 acquire: Effect.uninterruptibleMask((restore) =>
16 restore(amplifyTestLock.take(1)).pipe(
17 Effect.tap(() =>
18 Effect.sync(() => {
19 held = true;
20 }),
21 ),
22 Effect.asVoid,
23 ),
24 ),
25 release: Effect.suspend(() => {
26 if (!held) return Effect.void;
27 held = false;
28 return amplifyTestLock.release(1).pipe(Effect.asVoid);
29 }),
30 };
31 };