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

fix(download): prevent crashing race condition #29

Closed JorgenEvens closed 1 year ago

JorgenEvens commented 1 year ago

The downloadDatabases function awaits cleanupHotDownloadDir under the assumption that the cleanup has finished when the promise resolves.

cleanupHotDownloadDir however did not return a promise, as a consequence the downloadDatabases does not wait for the actual delete.

We've experienced several instances of our services failing to start because the target directory for the downloads do not exist. This happens when the cleanup happens after the fs.mkdirSync. This could happen if cleanup runs slower than the fs.mkdirSync call.

GitSquared commented 1 year ago

Just published v3.0.3 to npm