GitSquared / node-geolite2-redist

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

fix(download): prevent crashing race condition #29

Closed JorgenEvens closed 2 years ago

JorgenEvens commented 2 years 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 2 years ago

Just published v3.0.3 to npm