-
-
Notifications
You must be signed in to change notification settings - Fork 632
Description
Problem
The current uploadRaceCondition.test.ts uses a preHandler barrier to ensure both requests' onFile phases complete before either route handler runs. This proves that per-request upload directories prevent cross-contamination, but it doesn't guarantee that the actual asset copy operations inside the route handlers happen concurrently.
Because the barrier only synchronizes at the preHandler stage (after file upload, before handler execution), the route handlers may still execute sequentially in practice β one fully completing its lock-acquire β copy β unlock cycle before the other starts. This means the test may not exercise the per-bundle locking under true contention.
Suggested Improvement
Add a mechanism to verify that the critical sections (asset copy operations) overlap in time. For example:
- Instrument the lock/copy path with timestamps or counters to confirm both handlers hold or contend for locks simultaneously
- Add a second barrier inside the handler (e.g., after lock acquisition but before copy) to force true overlap of the copy phase
- Use a slow/large asset file to increase the window for overlap, combined with timing assertions
This would make the concurrency tests more robust and ensure the shared per-bundle lock is actually tested under contention rather than just sequential execution behind a barrier.
π€ Generated with Claude Code