Finding a lost song with Node.js & async iterators
summary
Uses Node.js and undici to crawl 250,000 Last.fm scrobbles, hits a weird pagination bug where API reports 50 records per page but returns 51 and shows duplicated entries from a sliding-window race. Switches from page counters to the timestamp `to` parameter to avoid duplicates, implements an async generator reader that yields each page, then runs a keyword scan and after about 30 minutes surfaces the forgotten track from nine years ago. Code and exercises are open source.
AI-written summary · about
chapters (13)
- 0:00Introduction and problem
- 1:53Exploring the Last.fm API
- 4:59Initial data fetching issues
- 7:06Fixing pagination with time-based windowing
- 9:11Turning solution into a library
- 12:21Async iterators vs callbacks
- 13:26Iterator vs iterable explained
- 16:14Generators for iteration
- 18:23Async iterator protocol
- 20:28Async generators
- 22:10Building the reader library
- 23:16Searching for the lost song
- 23:57Finding the song
