GitSquared / GitSquared/node-geolite2-redist

Crashes the server when Github is down

Open
#64 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
121
Forks
19
PR merge metrics
No merged PRs in 30d

Description

Github was down the other day while I was working on a project and suddenly the server crashed on every request. I got `429 Too many requests` responses in the logs, and there doesn't seem to be any way to properly handle this error, because the initial check runs in the background:

https://github.com/GitSquared/node-geolite2-redist/blob/77b5ec44b8b5cd2b241db57cb5db77133d8f4c7d/src/auto-updater.ts#L35-L39

An easy way to test this is with this minimal example:
```js
import { open, GeoIpDbName } from 'geolite2-redist'

async function run() {
console.log('Attempting to open database...')
try {
await open(GeoIpDbName.Country, path => {
console.log('Callback fired')
return {}
})
console.log('Database opened successfully!')
} catch (err) {
console.error('This will never be reached because the crash happens in the background')
}

// Keep process alive to allow the floating promise to crash it
setTimeout(() => {
console.log('If you see this, the process survived.')
}, 2000)
}

run()
```

If Github is available then everything works and you get:
```
Attempting to open database...
Callback fired
Database opened successfully!
If you see this, the process survived.
```

But if you turn off your internet and run it that way, the server will crash.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/auto-updater.ts at lines 35-39, then run the minimal example from the issue with GitHub unavailable to reproduce the background failure. Trace how the initial check reports its 429 or network error and verify the completed behavior by confirming the process stays alive and the failure is handled without crashing the server.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, node.js, typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.