mirror of
https://github.com/direct-img/direct-img.link.git
synced 2026-10-14 08:47:53 +00:00
Two misses for the same query at once each ran their own search (ntfy showed Search #24 and #25 for one image). An in-memory fix wouldn't hold: a test of concurrent same-query requests on this project found they share an isolate only ~25% of the time. The rate-limit query is now one transaction that also claims a per-query lock, so it's still a single SurrealDB round trip. Requests that find the lock held write nothing (so aren't counted), poll until it's released, then serve the image from R2. Write conflicts roll the whole transaction back and are retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>