Async Nightmares
Promises, race conditions, and forgotten awaits
The asynchronous bugs that silently swallow data: un-awaited promises, forEach loops with async callbacks, and race conditions.
Your Progress
0 of 5 completed
Challenges in this collection
- 1
Doubling with forEach returns an empty list
doubleAll(nums) doubles every number with fetchDouble, which takes a moment, and returns the results. Example: await doubleAll([1, 2, 3]) → [2, 4, 6].
javascripthard - 2
Total shows "[object Promise]" instead of 6
sumDelayed(nums) adds up numbers that each arrive after a short delay. Example: await sumDelayed([1, 2, 3]) → 6.
javascriptmedium - 3
Word lengths come back as promises, not numbers
wordLengths(words) returns the length of each word. Example: await wordLengths(["abc", "defg"]) → [3, 4].
javascriptmedium - 4
Adding 4 votes at once keeps only the last
tallyVotes(votes) adds up every vote. The votes are counted at the same time with Promise.all. Example: await tallyVotes([1, 2, 3, 4]) → 10.
javascripthard - 5
3 people book the last seat
bookSeats(n) sends n booking requests at the same time for 1 remaining seat, and returns how many bookings succeeded. It should never be more than 1. Example: await bookSeats(3) → 1.
javascripthard
More collections to explore
Your First 5 Bugs
Five beginner-friendly bugs with clear symptoms and satisfying fixes. The best place to start if you are new to debugging.
Python Gotchas
Mutable default arguments, list.sort() returning None, and mutating a list while iterating over it.
JavaScript Type Coercion Traps
Accidental string concatenation, array sort ordering numbers alphabetically, and zero being falsely treated as missing.
The Off-By-One Gauntlet
Fencepost errors, inclusive vs exclusive slice bounds, and loops that step one position too far.
AI Code Comprehension
Simulate modern Code Comprehension rounds: classic coding questions written by an AI that pass the obvious test, but break on subtle edge cases.