Skip to content
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

fs: mkdtemp should not fail if no callback passed #6828

Closed

Conversation

thefourtheye
Copy link
Contributor

Checklist
  • tests and code linting passes
  • a test is included
  • the commit message follows commit guidelines
Affected core subsystem(s)

fs

Description of change

As it is, fs.mkdtemp crashes with a C++ assertion if the callback
function is not passed. This patch uses maybeCallback to create one,
if no callback function is passed.

@thefourtheye thefourtheye added the fs Issues and PRs related to the fs subsystem / file system. label May 18, 2016
@thefourtheye thefourtheye force-pushed the fix-fs-mkdtemp-callback branch from 8235c32 to 66a5666 Compare May 18, 2016 05:10
@mscdex
Copy link
Contributor

mscdex commented May 18, 2016

LGTM.

On an unrelated note, how about moving the fs.mkdtemp*() functions earlier in the source file so that they are alongside the other fs.* function definitions?

@jasnell
Copy link
Member

jasnell commented May 18, 2016

LGTM if CI is green

@mscdex
Copy link
Contributor

mscdex commented May 18, 2016

@thefourtheye thefourtheye force-pushed the fix-fs-mkdtemp-callback branch 3 times, most recently from 49a7016 to b50654d Compare May 18, 2016 06:59
@thefourtheye
Copy link
Contributor Author

@mscdex I moved them and changed var req = to const req =.

@mscdex
Copy link
Contributor

mscdex commented May 18, 2016

@thefourtheye Looks better now. However you might make the code move a separate commit so that the callback change is more easily visible.

@thefourtheye thefourtheye force-pushed the fix-fs-mkdtemp-callback branch from b50654d to 0a87d37 Compare May 18, 2016 11:59
@thefourtheye
Copy link
Contributor Author

@mscdex Oh yes. This is better now. Thanks :-) PTAL.

@@ -2000,7 +2000,8 @@ SyncWriteStream.prototype.destroy = function() {

SyncWriteStream.prototype.destroySoon = SyncWriteStream.prototype.destroy;

fs.mkdtemp = function(prefix, options, callback) {
fs.mkdtemp = function(prefix, options, callback_) {
let callback = maybeCallback(callback_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: might change this to var callback to be consistent with the rest of fs. Also let in general is still slow IIRC, although whether that will matter in the grand scheme of things in this particular case is hard to say.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mscdex Sorry, I made a big mess out of this small change. PTAL now. I updated.

As it is, `fs.mkdtemp` crashes with a C++ assertion if the callback
function is not passed. This patch uses `maybeCallback` to create one,
if no callback function is passed.
@thefourtheye thefourtheye force-pushed the fix-fs-mkdtemp-callback branch from 0a87d37 to daa3750 Compare May 18, 2016 12:17
@mscdex
Copy link
Contributor

mscdex commented May 18, 2016

CI again just to be safe: https://ci.nodejs.org/job/node-test-pull-request/2690/

jasnell pushed a commit that referenced this pull request May 20, 2016
As it is, `fs.mkdtemp` crashes with a C++ assertion if the callback
function is not passed. This patch uses `maybeCallback` to create one,
if no callback function is passed.

PR-URL: #6828
Reviewed-By: Brian White <[email protected]>
Reviewed-By: James M Snell <[email protected]>
jasnell pushed a commit that referenced this pull request May 20, 2016
PR-URL: #6828
Reviewed-By: Brian White <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@jasnell
Copy link
Member

jasnell commented May 20, 2016

Landed in dcbf246 and 79a5eb1

@jasnell jasnell closed this May 20, 2016
@thefourtheye thefourtheye deleted the fix-fs-mkdtemp-callback branch May 20, 2016 15:36
Fishrock123 pushed a commit that referenced this pull request May 23, 2016
As it is, `fs.mkdtemp` crashes with a C++ assertion if the callback
function is not passed. This patch uses `maybeCallback` to create one,
if no callback function is passed.

PR-URL: #6828
Reviewed-By: Brian White <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Fishrock123 pushed a commit that referenced this pull request May 23, 2016
PR-URL: #6828
Reviewed-By: Brian White <[email protected]>
Reviewed-By: James M Snell <[email protected]>
rvagg pushed a commit that referenced this pull request Jun 2, 2016
As it is, `fs.mkdtemp` crashes with a C++ assertion if the callback
function is not passed. This patch uses `maybeCallback` to create one,
if no callback function is passed.

PR-URL: #6828
Reviewed-By: Brian White <[email protected]>
Reviewed-By: James M Snell <[email protected]>
rvagg pushed a commit that referenced this pull request Jun 2, 2016
PR-URL: #6828
Reviewed-By: Brian White <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants