-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Change in fs.statSync behavior between 7.1.0 and 7.2.0 #10242
Comments
cc @nodejs/fs @saghul |
Revised test: 'use strict';
const fs = require('fs');
const buffer = Buffer.alloc(16);
const FILENAME = '/tmp/test';
fs.writeFileSync(FILENAME, 'wx');
const fd = fs.openSync(FILENAME, 'a');
fs.writeSync(fd, buffer);
fs.fsyncSync(fd);
fs.closeSync(fd);
var stats = fs.statSync(FILENAME);
console.log(stats.size);
//fs.unlinkSync(FILENAME);
from node v7.2.1-pre:
If the script is changed to use const buffer = Buffer.alloc(16, 'abc'); output from v6.9.1 is
whereas v7.2.1-pre is
EDIT: This was running on Linux 4.4.0 x64 using ext4 EDIT 2: Accidentally wrote |
Okay, try this again. Slightly simplified test that demonstrates the same as in the OP: 'use strict';
const fs = require('fs');
const FILENAME = '/tmp/test';
fs.writeFileSync(FILENAME, Buffer.alloc(0), { flag: 'wx' });
const fd = fs.openSync(FILENAME, 'a');
fs.writeSync(fd, Buffer.alloc(16, 'abc'));
console.log(fs.statSync(FILENAME).size);
fs.closeSync(fd); On v6.9.1 output is |
@sharkinsspatial In short, this actually don't have to do w/ |
I tried adding a With 7.1.0: binding.writeBuffer(9, <Buffer 61 62 63 61 62 63 61 62 63 61 62 63 61 62 63 61>, undefined, undefined, null); With 7.2.0: binding.writeBuffer(9, <Buffer 61 62 63 61 62 63 61 62 63 61 62 63 61 62 63 61>, 0, 16, null); It looks correct to me, though -- but maybe it's surfacing a problem with |
@nodejs/ctc has everyone seen this? Is there any action to be done? |
It seems like the difference in behavior kicks in here. With 7.1.0, uv_buf_t uvbuf = uv_buf_init(const_cast<char*>(buf), len); ... but in 7.2.0 The libuv docs don't say explicitly what passing 0 means, but a bit of logging ( It seems like the behavior of 7.2.0 is the correct one. It's just that @sharkinsspatial, what exactly did you expect the snippet to do? Did you just observe that the behavior changed? |
Sorry for the delay in response (holiday vacation). For me the 7.2.0 is the correct expected behavior. I just ran into an issue when I deployed to a pre-7.2.0 environment and the behavior changed. This discussion explains it clearly for me. |
@sharkinsspatial Okay, thanks for clarifying :) I believe we can close this issue. |
I feel that this has to be documented somewhere. |
@thefourtheye, which part exactly? The way I see it, the implementation of |
It sounds like this issue can be closed (reopen if you disagree). |
I noted a change in behavior between fs.statSync when migrating between 7.1.0 and 7.2.0. With
7.1.0 the following code reports a file size of 0.
While using 7.2.0 it reports a file size of 16.
Interestingly using appendFileSync rather than opening file handles is not affected by version differences. The Changelog notes a libuv upgrade between the two versions but I'm unsure what could produce this change.
The text was updated successfully, but these errors were encountered: