Hello! Perhaps, you are trying to create a Buffer of negative length?
Also, I believe, that you do not need to pass encoding argument to the Buffer's constructor if you're creating just a fixed-size buffer. On Mon, Dec 9, 2013 at 1:58 PM, Felipe Silveira <[email protected]> wrote: > Hi There, > > I'm trying to tail a file in nodejs, the code is this: > > var fs = require('fs'); > var fName = 'file.txt'; > fNameStat = fs.statSync(fName); > fs.watch(fName, function (evento, arquivo) { > fNameStatChanged = fs.statSync(arquivo); > console.log('file changed from ' + fNameStat.size + ' to ' + > fNameStatChanged.size); > fs.open(fName, 'r', function(err, fd) { > var newDataLength = fNameStatChanged.size - fNameStat.size; > console.log(newDataLength); > var buffer = new Buffer(newDataLength, 'utf-8'); > console.log(buffer); > console.log(fd); > fs.read(fd, buffer, 0, newDataLength, null, function (err, > bytesRead, newData) { > if (err) { > console.log(err); > }; > console.log(newData.toString()); > > }); > fNameStat = fs.statSync(fName); > }); > > }); > > > I'm getting this error: > > fs.js:267 > binding.read(fd, buffer, offset, length, position, wrapper); > ^ > Error: Offset is out of bounds > at Object.read (fs.js:267:11) > at Object.oncomplete (/var/www/read/test.js:13:15) > > Anyone know whats happened? > > Regards, > > Felipe Silveira Mendes > Site - Twitter - Blog > Web Developer > (31) 8370-9090 (Claro) > (31) 9433-9310 (Tim) > [email protected] > > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
