Skip to content

Commit 44f38ea

Browse files
committed
Update CLAUDE.md
1 parent 13101ca commit 44f38ea

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@
5555
- TypeScript strict mode enabled
5656
- Tailwind CSS classes should be sorted (biome `useSortedClasses` rule)
5757

58+
### Async Cleanup Ordering
59+
60+
When tearing down async operations that use an AbortController, always abort the controller **before** awaiting any cleanup that depends on it. Otherwise you get a deadlock: the cleanup waits for the operation to stop, but the operation won't stop until the abort signal fires.
61+
62+
```typescript
63+
// WRONG - deadlocks if interrupt() waits for the operation to finish
64+
await this.interrupt(); // hangs: waits for query to stop
65+
this.abortController.abort(); // never reached
66+
67+
// RIGHT - abort first so the operation can actually stop
68+
this.abortController.abort(); // cancels in-flight HTTP requests
69+
await this.interrupt(); // resolves because the query was aborted
70+
```
71+
5872
### Avoid Barrel Files
5973

6074
- Do not make use of index.ts

0 commit comments

Comments
 (0)