You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug report] fs.createReadStream set highWaterMark, the same file get different result #35465
when bytesRead === 0 why poolFragments.push(thisPool.slice(alignedStart, alignedEnd));
node-v12.2.0/lib/internal/fs/streams.js
ReadStream.prototype._read=function(n){if(typeofthis.fd!=='number'){returnthis.once('open',function(){this._read(n);});}if(this.destroyed)return;if(!pool||pool.length-pool.used<kMinPoolSpace){// Discard the old pool.allocNewPool(this.readableHighWaterMark);}// Grab another reference to the pool in the case that while we're// in the thread pool another read() finishes up the pool, and// allocates a new one.constthisPool=pool;lettoRead=Math.min(pool.length-pool.used,n);conststart=pool.used;if(this.pos!==undefined)toRead=Math.min(this.end-this.pos+1,toRead);elsetoRead=Math.min(this.end-this.bytesRead+1,toRead);// Already read everything we were supposed to read!// treat as EOF.if(toRead<=0)returnthis.push(null);// the actual read.fs.read(this.fd,pool,pool.used,toRead,this.pos,(er,bytesRead)=>{if(er){if(this.autoClose){this.destroy();}this.emit('error',er);}else{letb=null;// Now that we know how much data we have actually read, re-wind the// 'used' field if we can, and otherwise allow the remainder of our// reservation to be used as a new pool later.if(start+toRead===thisPool.used&&thisPool===pool){console.log('newUsed')constnewUsed=thisPool.used+bytesRead-toRead;thisPool.used=roundUpToMultipleOf8(newUsed);}else{console.log('alignedEnd')console.log('bytesRead: '+bytesRead)// Round down to the next lowest multiple of 8 to ensure the new pool// fragment start and end positions are aligned to an 8 byte boundary.constalignedEnd=(start+toRead)&~7;constalignedStart=roundUpToMultipleOf8(start+bytesRead);if(alignedEnd-alignedStart>=kMinPoolSpace){console.log('start: '+start)console.log('toRead: '+toRead)console.log('alignedEnd: '+alignedEnd)console.log('alignedStart: '+alignedStart)poolFragments.push(thisPool.slice(alignedStart,alignedEnd));}}if(bytesRead>0){this.bytesRead+=bytesRead;b=thisPool.slice(start,start+bytesRead);}this.push(b);}});
Hi, is there an update on this? Do you think it'll make it into 12.x or 14.x? I don't have a ton of extra time, but if you give me some direction, I can take a swing at fixing it.
Activity
Zclhlmgqzc commentedon Oct 5, 2020
@bnoordhuis
@trxcllnt
when bytesRead === 0 why poolFragments.push(thisPool.slice(alignedStart, alignedEnd));
node-v12.2.0/lib/internal/fs/streams.js
Zclhlmgqzc commentedon Oct 6, 2020
Works fine
node-12.2.0/12.18.4/14.13.0
/lib/internal/fs/streams.js
ronag commentedon Oct 10, 2020
@Zclhlmgqzc PR welcome! Do you have the same issue on Node 15/master?
Zclhlmgqzc commentedon Oct 14, 2020
@ronag
Works fine in Node 15.x
Because #33981
gblock0 commentedon Mar 23, 2021
Hi, is there an update on this? Do you think it'll make it into 12.x or 14.x? I don't have a ton of extra time, but if you give me some direction, I can take a swing at fixing it.
targos commentedon May 3, 2023
Closing as v14.x is EoL.