Skip to content

Comments

fix: stronger cache hash (FNV-1a 64-bit) and GeoIP abort on timeout#210

Open
Rau1CS wants to merge 1 commit intokoala73:mainfrom
Rau1CS:fix/stronger-hash-and-geoip-abort
Open

fix: stronger cache hash (FNV-1a 64-bit) and GeoIP abort on timeout#210
Rau1CS wants to merge 1 commit intokoala73:mainfrom
Rau1CS:fix/stronger-hash-and-geoip-abort

Conversation

@Rau1CS
Copy link
Contributor

@Rau1CS Rau1CS commented Feb 20, 2026

Summary

  • Replace 32-bit hash with stronger hash for cache keys #180: Replaced the 32-bit DJB2 hashString() in _upstash-cache.js with FNV-1a 64-bit using BigInt. The birthday-bound collision threshold goes from ~65K to ~4B entries — a 65,000x improvement while remaining synchronous and edge-runtime compatible. All 5 caller files are unchanged.
  • Cancel background GeoIP workers on timeout #196: The GeoIP worker pool in cyber-threats.js used Promise.race to enforce an overall timeout, but the losing workers (and their in-flight fetch calls) kept running. Now an AbortController signal is threaded through hydrateThreatCoordinates → geolocateIp → fetchGeoIp → fetchJsonWithTimeout, so all pending requests are cancelled the moment the overall timeout fires.

Changes

File What changed
api/_upstash-cache.js hashString(): DJB2 32-bit → FNV-1a 64-bit (BigInt)
api/cyber-threats.js hydrateThreatCoordinates: create AbortController, pass signal through worker chain; fetchJsonWithTimeout: forward external abort signal; fetchGeoIp / geolocateIp: accept + pass signal parameter

Checklist

  • npx tsc --noEmit passes
  • No new dependencies
  • No secrets or API keys
  • Edge-runtime compatible (no node:crypto, uses BigInt + standard AbortController)
  • Backwards-compatible (hashString signature unchanged; new signal params are optional)

Closes #180, closes #196

🤖 Generated with Claude Code

…rs on timeout

hashString() used a 32-bit DJB2 hash prone to collisions at scale; replaced
with FNV-1a 64-bit (BigInt) for ~2^32 birthday-bound collision resistance
while staying synchronous and edge-runtime compatible.

GeoIP worker pool in cyber-threats used Promise.race without cancelling
in-flight fetches on timeout. Now threads AbortController signal through
workers → geolocateIp → fetchGeoIp → fetchJsonWithTimeout so all pending
requests are aborted when the overall timeout fires.

Closes koala73#180, closes koala73#196

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 20, 2026

@Rau1CS is attempting to deploy a commit to the Elie Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cancel background GeoIP workers on timeout Replace 32-bit hash with stronger hash for cache keys

1 participant