- Version: v11.3.0
- Platform: Win 10
Test case:
var fs = require('fs').promises;
async function bug() {
await fs.writeFile('test', '012345678901234567890123456789');
const fd = await fs.open('test', 'r+');
await fd.readFile({ encoding: 'utf8' });
await fd.truncate(0);
await fd.writeFile('Extra data not at beginning');
await fd.close();
}
bug();
This will result a file with lots of '\0' at beginning of the file.
And w/o the ability to seek, there is no way to write at the beginning of the file.