GitSquared / node-geolite2-redist

Redistribution of MaxMind GeoLite2 GeoIP databases as an npm library
https://gitsquared.github.io/node-geolite2-redist/
Other
72 stars 15 forks source link

Invalid Extended Type at offset 0 val 7 #5

Closed natanavra closed 4 years ago

natanavra commented 4 years ago

Hard to re-produce as it is inconsistent and happens only sometimes. Seems like the db becomes corrupted and maxmind is unable to read the file. The solution is to npm remove geolite2-redist and npm install to re-download the db.

Any ideas?

GitSquared commented 4 years ago

Interesting.

https://github.com/GitSquared/node-geolite2-redist/blob/32096c0ca50aab6d7c33e5856ae13235d7866c1f/scripts/download-helper.js#L79-L83

The downloader script directly overwrites the database files. I guess if you kill the app while geolite2-redist is updating/unzipping, or if you lose internet connectivity, the files are effectively left in a corrupted state.

Solution: write to temporary files. Rename them if checksums pass. Delete any temporary files on startup.

Will publish an update soon.

natanavra commented 4 years ago

Seems like this issue is still there, haven't seen the error for a while

ENOENT: no such file or directory, rename '.../node_modules/geolite2-redist/dbs-tmp
ENOENT: no such file or directory, open '.../node_modules/geolite2-redist/dbs/GeoLite2-City.mmdb'
GitSquared commented 4 years ago

Have you upgraded the lib lately? Can you confirm it stops working after printing out these errors?

natanavra commented 4 years ago

I'm on the latest 1.0.7 The app crashes with "uncaught exception", seems like it's working after a restart But in general, totally came out of the blue in a production deployment

GitSquared commented 4 years ago

I'll look into it.