Skip to content

Commit cd12251

Browse files
committed
Update CLAUDE.md
1 parent 586bafe commit cd12251

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
@@ -48,6 +48,20 @@
4848
- TypeScript strict mode enabled
4949
- Tailwind CSS classes should be sorted (biome `useSortedClasses` rule)
5050

51+
### Async Cleanup Ordering
52+
53+
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.
54+
55+
```typescript
56+
// WRONG - deadlocks if interrupt() waits for the operation to finish
57+
await this.interrupt(); // hangs: waits for query to stop
58+
this.abortController.abort(); // never reached
59+
60+
// RIGHT - abort first so the operation can actually stop
61+
this.abortController.abort(); // cancels in-flight HTTP requests
62+
await this.interrupt(); // resolves because the query was aborted
63+
```
64+
5165
### Avoid Barrel Files
5266

5367
- Do not make use of index.ts

0 commit comments

Comments
 (0)