Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Extended Type at offset 0 val 7 #62

Closed
sunknudsen opened this issue Mar 7, 2017 · 6 comments
Closed

Invalid Extended Type at offset 0 val 7 #62

sunknudsen opened this issue Mar 7, 2017 · 6 comments

Comments

@sunknudsen
Copy link

Hey guys,

Using watchForUpdates : true

When I run the following:

wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
gunzip -f GeoLite2-City.mmdb.gz

My app crashes with errors:

"error": {
"message": "ENOENT: no such file or directory, open './GeoLite2-City.mmdb'",
"stack": "Error: ENOENT: no such file or directory, open './GeoLite2-City.mmdb'\n at Error (native)\n"
}

"error": {
"message": "Invalid Extended Type at offset 0 val 7",
"stack": "Error: Invalid Extended Type at offset 0 val 7\n at Decoder.decode (/node_modules/maxmind/lib/decoder.js:54:13)\n at new Metadata (/node_modules/maxmind/lib/metadata.js:15:26)\n at Reader.load (/node_modules/maxmind/lib/reader.js:27:19)\n at new Reader (/node_modules/maxmind/lib/reader.js:21:8)\n at ***/node_modules/maxmind/index.js:18:18\n at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)\n"
}

Once the app is reloaded, all is good.

Is this a timing issue?

Best,

Sun

@runk
Copy link
Owner

runk commented Mar 7, 2017

Feels that your'e trying to use .gz file. I think I might add a check for this.

@sunknudsen
Copy link
Author

sunknudsen commented Mar 7, 2017

Hi @runk,

I updated my script to extract and them override GeoLite2-City.mmdb.

wget -O ./GeoLite2-City.mmdb.gz http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
gunzip -c ./GeoLite2-City.mmdb.gz > ./GeoLite2-City.mmdb.tmp
mv ./GeoLite2-City.mmdb.tmp ./GeoLite2-City.mmdb

My bet is that the node file watch was trying to open the file as it was being extracted. Makes sense?

Will report back tomorrow to close the issue if the fix worked in production.

Thanks for the great library by the way!

Sun

@runk
Copy link
Owner

runk commented Mar 8, 2017

I've added a check for gzip format in v2.2.0 - you can check it out.

@sunknudsen
Copy link
Author

Hey @runk,

The problem appears to be that { watchForUpdates: true } was trying to load the .mmdb file as it was being extracted.

Using a tmp file and then calling mv fixed the timing issue.

wget -O ./GeoLite2-City.mmdb.gz http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
gunzip -c ./GeoLite2-City.mmdb.gz > ./GeoLite2-City.mmdb.tmp
mv ./GeoLite2-City.mmdb.tmp ./GeoLite2-City.mmdb

Have a great day,

Sun

@runk
Copy link
Owner

runk commented Mar 8, 2017

A-ha! Good old race condition.

@natanavra
Copy link

natanavra commented Mar 31, 2020

Sorry to revive an old thread, I'm putting this as a note in case anyone else faces this issue.
If you're using geolite2-redist, seems sometimes data becomes corrupted and the only way to fix it is to remove npm remove geolite2-redist and then npm install.

Opened an issue on geolite2-redist repo: GitSquared/node-geolite2-redist#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants