EBADF, bad file descriptor
Hi I am getting a bad file descriptor error.
Here is the code
var maxmind = require('maxmind');
maxmind.init(['./geoip/GeoIPCity.dat', './geoip/GeoIPISP.dat'], {indexCache: true, memoryCache: true});
fs.js:476
var r = binding.read(fd, buffer, offset, length, position);
^
Error: EBADF, bad file descriptor
at Object.fs.readSync (fs.js:476:19)
at File.readFully (/home/ubuntu/vic/dna/node_modules/maxmind/lib/file.js:34:16)
at Database.init (/home/ubuntu/vic/dna/node_modules/maxmind/lib/database.js:59:17)
at new Database (/home/ubuntu/vic/dnd/node_modules/maxmind/lib/database.js:25:8)
at Object.exports.init (/home/ubuntu/vic/dna/node_modules/maxmind/lib/lookup_service.js:49:15)
at Object.<anonymous> (/home/ubuntu/vic/dna/logic/rtbtwo_parser.js:32:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
When i delete the memoryCache: true it works fine.
Could you please check it what i am doing wrong here.
Hi there, this is very unusual. Are you able to constantly reproduce it?
Usually it happens when ReadStream is closed or file deleted/moved.
@runk yup i have tried it on three different machines, my mac and two different ec2 with ubuntu and amazon linux os.
So, you can even reproduce this issue with basic file of two lines?
var maxmind = require('maxmind');
maxmind.init(['./geoip/GeoIPCity.dat', './geoip/GeoIPISP.dat'], {indexCache: true, memoryCache: true});
I want to make sure there are no interference from some other stuff.
A-ha. I got it. You're using two options {indexCache: true, memoryCache: true} which shouldn't be used together. I'll add a fix.
Fixed in https://github.com/runk/node-maxmind/commit/cbeb6d95ed5f62ef60e9724bb978278bf0940c1e.
Version 0.5.5 published.
Thanks for feedback :100:
Thanks for patch, actually i haven't found anything in the documentation thats why i mixed these two {indexCache: true, memoryCache: true}.
:+1: