GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fs/promises: ensure options.flag is defaulted to 'r' in readFile by bdistin · Pull Request #20268 · nodejs/node Conversation
|
|
@nodejs/fs |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
76a8dbb to
58b874d
Compare
|
I'm curious if the behavior of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This will actually manipulate the passed in options because getOptions does not copy the options object.
Please do:
if (options.flag == null) { options = copyObject(options); options.flag = 'r'; }
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ronkorving you are right in a way: the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
58b874d to
c64b578
Compare
|
No longer manipulates the passed in options. Since options.flag is not needed in readFileHandle(), copied the existing style from writeFile() instead of null check + copyObject(). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@nodejs/fs Please have a look at this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I see that the fs/promises API has been moved to fs.promises, causing conflicts in this pr. Should I resolve those conflicts? (This is my first pr to Node, so I am still a bit unsure of the processes expected.) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
3e0d004 to
f5a462f
Compare
When passing {} or { encoding: 'utf8' } as options to readFile, the
flag is not defaulted to 'r' unlike normal fs. This fix makes
(fs/promises).readFile() act consistently with fs.readFile().
|
Also given the changes of the fs/promises paradigm, should the pr/commit be named just |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Is there anything more I need to do? I can't explain how the Windows 2016 binary tests fail, and can't see how that would be related to the changes made in this pr. If this is something I need to fix, can anyone shed light on what changes I might need to make? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Windows CI rerun: https://ci.nodejs.org/job/node-test-commit-windows-fanned/17969/ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
So that CI seemed to have passed, but the checks weren't updated on this pr. Does that mean this is good to go? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
bump? @nodejs/fs ?? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I would've expected that getOptions should extend fields of the options if they are not present..but the current fix works as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
New CI: https://ci.nodejs.org/job/node-test-pull-request/15107/ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const { promises: fs } = require('fs'); | ||
| const fixtures = require('../common/fixtures'); | ||
|
|
||
| const fn = fixtures.path('empty.txt'); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
fail on unhandled rejection
Sorry, something went wrong.
There was an error while loading. Please reload this page.
common was required, but not assigned to common in order for the requested change to work.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
It seems with the test fixes, the tests have uncovered another bug: https://github.com/nodejs/node/blob/master/lib/internal/fs/promises.js#L140-L141 How should I handle that bug? Should I increase the scope of this pr to fix that bug as well? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| .then(assert.ok); | ||
|
|
||
| fs.readFile(fn, 'utf8') | ||
| .then(assert.strictEqual.bind(this, '')); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
fs: return string on empty fs.promises.readfile when encoding provided fs.promises.readfile() would provide a buffer whenever an empty file is read, when it should have returned an empty string when encoding is provided.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Landed in 2cd3e61 🎉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
When passing {} or { encoding: 'utf8' } as options to readFile, the
flag is not defaulted to 'r' unlike normal fs. This fix makes
fs.promises.readFile() act consistent with fs.readFile().
It also fixes another issue with fs.promises.readfile() where it
returned a Buffer instead of an empty string when encoding is provided.
PR-URL: nodejs#20268
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ron Korving <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
When passing {} or { encoding: 'utf8' } as options to readFile, the
flag is not defaulted to 'r' unlike normal fs. This fix makes
fs.promises.readFile() act consistent with fs.readFile().
It also fixes another issue with fs.promises.readfile() where it
returned a Buffer instead of an empty string when encoding is provided.
PR-URL: #20268
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ron Korving <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.