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

Error: ENOENT: no such file or directory, rename #34

Open joshmanders opened 3 months ago

joshmanders commented 3 months ago

I keep periodically getting this error. Using geolite2-redist@3.0.4.

Error: ENOENT: no such file or directory, rename '[...]/node_modules/geolite2-redist/dbs.geodownload/GeoLite2-City.mmdb' -> '[...]/node_modules/geolite2-redist/dbs/GeoLite2-City.mmdb'
    at Object.renameSync (node:fs:1032:11)
    at [...]/node_modules/geolite2-redist/dist/download-helpers.js:87:16
GitSquared commented 3 months ago

Thanks for the report Josh

Looks like the library is failing to download a database update, are you running behind a firewall by any chance? If so, you might have to whitelist some IPs so it can reach the GitHub mirror – see the last bit of this section of the README

Let me know if that fix things up!


Affected code is here for ref: https://github.com/GitSquared/node-geolite2-redist/blob/acf9b7e98f949f9930ae44da0af52b4f4542d4c8/src/download-helpers.ts#L141

joshmanders commented 3 months ago

Nope no firewall afaik, it happens periodically both locally in development and in production.

natanavra commented 6 days ago

+1 started getting this error today we've been working with the package for several years

GitSquared commented 6 days ago

@natanavra could you give me a bit more info about the environment you're running the package in?

Possible root causes include bad network access, missing write permissions on disk. I checked and the redist tarballs are properly formatted.

Today was the first redist update in 3 months, so anything that might have changed in your infra since 3 months ago might be a good lead to follow

natanavra commented 6 days ago

@GitSquared No changes in infra whatsoever Amazon Linux / Ubuntu 20 + NodeJS 16-18 (several environments)

Been getting this error on several projects starting this morning

Specifically: ENOENT: no such file or directory, rename '.../node_modules/geolite2-redist/dbs.geodownload/GeoLite2-City.mmdb' -> '.../node_modules/geolite2-redist/dbs/GeoLite2-City.mmdb'

natanavra commented 6 days ago

Something very bad is going on with the db download Getting more errors: Checksum mismatch for GeoLite2-City ENOENT: Cannot cd into '/home/ubuntu/server/node_modules/geolite2-redist/dbs.geodownload

@GitSquared Can you rollback the deployed version?

This is breaking the whole process right, and there isn't much that can be done, it's throwing unhandled promise rejections The whole auto-update operation should be wrapped and send out warnings instead

GitSquared commented 6 days ago

@natanavra I just released https://github.com/GitSquared/node-geolite2-redist/releases/tag/v3.1.0 which should improve error and filesystem handling.

Let me know if that improves stuff on your end. I couldn't manage to reproduce the issue you're having while doing some tests locally.

natanavra commented 6 days ago

@GitSquared Thanks! I worked around it in the meantime by manually updating the db file in the dist folder

natanavra commented 6 days ago

May I suggest adding an event listener instead of throwing an error? Or even adding a callback parameter that could be passed and called instead of throwing an error. If there's a callback - great call it If not - throw an error

GitSquared commented 5 days ago

Yes that's a good idea! Will implem whenever I have time.