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

src: remove 2nd undefined argument in node_file.cc #20629

Closed
wants to merge 1 commit into from

Conversation

dankang
Copy link
Contributor

@dankang dankang commented May 9, 2018

In the document for fs, there are several functions that state "No
arguments other than a possible exception are given to the completion
callback." (ex> fs.access, fs.chmod, fs.close, ..)

But, the functions are invoking the callback with two parameters (err,
undefined)

It causes problems in using several API like
async.waterfall.

Fixes: #20335

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows [commit guidelines]

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. labels May 9, 2018
@mscdex
Copy link
Contributor

mscdex commented May 9, 2018

src/node_file.cc Outdated
MakeCallback(env()->oncomplete_string(), arraysize(argv), argv);
int len = arraysize(argv);
MakeCallback(env()->oncomplete_string(),
len == 2 && value->IsUndefined() ? 1 : len,
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the length check here redundant as it will always be 2? Why not just check the undefined-ness?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, right. I fixed.
I thought somebody can modify the function to multiple arguments, but too much worry.

@mscdex
Copy link
Contributor

mscdex commented May 9, 2018

The newly added test seems to be causing a hard crash.

@dankang
Copy link
Contributor Author

dankang commented May 9, 2018

@mscdex I divided the test case into 2 different cases.
(test-fs-close-cb-parameters.js is from #20335)
I can't test them right now because of my battery, will check them later if it is ok.

@mscdex
Copy link
Contributor

mscdex commented May 9, 2018

@mscdex
Copy link
Contributor

mscdex commented May 9, 2018

It seems sequential/test-fs-close-cb-parameters.js is the one crashing now.

@dankang
Copy link
Contributor Author

dankang commented May 10, 2018

@mscdex I modified the test cases.
Could you please start a CI run?

  • use existing test case for fs.access()
    • remove sequential/test-fs-access-cb-parameters.js
    • add parameter checking code in parallel/test-fs-access.js
  • move test case for fs.close()
    • remove sequential/test-fs-close-cb-parameters.js
    • add a simple test case to parallel/test-fs-close.js

@mscdex
Copy link
Contributor

mscdex commented May 10, 2018

@dankang
Copy link
Contributor Author

dankang commented May 10, 2018

Tests failed in several linux versions.
I will set up one of the linux systems and run tests on it.

@dankang
Copy link
Contributor Author

dankang commented May 10, 2018

I set an ubuntu1710-x64 system on AWS that had failed in the CI node-test-commit-linux.
But, the test is succesful in my system.

Also, I tested it on debian9-64 on AWS, it was successful.
I couldn't test it on ubuntu1604-32, because there is no image on AWS.

  • ubuntu1710-64: Successful
  • debian9-64: Successful
  • ubuntu1604-32: not tested

Could you please tell me what I should do more in this case?

@mscdex
Copy link
Contributor

mscdex commented May 10, 2018

I think those are just unrelated, flaky failures.

@dankang
Copy link
Contributor Author

dankang commented May 10, 2018

I rebased master branch and tested on 3 different linux systems.
Can you run a CI test again?

@joyeecheung
Copy link
Member

@dankang dankang closed this May 10, 2018
@dankang dankang reopened this May 10, 2018
@dankang
Copy link
Contributor Author

dankang commented May 10, 2018

In this time, the CI run failed at fetching git repo step in osx.

@dankang dankang force-pushed the fs-callback branch 5 times, most recently from 3835724 to 7b958c3 Compare May 11, 2018 14:22
@dankang
Copy link
Contributor Author

dankang commented May 11, 2018

I rebased master and merged my commits.
And, I ran test in below 4 environments.

  • osx
  • ubuntu 1604-64
  • ubuntu 1710-64
  • debian9-64

Can anybody run a CI test?
Or, anybody comment about my commit?

@joyeecheung
Copy link
Member

In the document for fs, there are several functions that state "No
arguments other than a possible exception are given to the completion
callback." (ex> fs.access, fs.chmod, fs.close, ..)

But, the functions are invoking the callback with two parameters (err,
undefined)

It causes problems in using several API like
[async.waterfall](https://caolan.github.io/async/docs.html#waterfall).

Fixes: nodejs#20335
@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 18, 2018
@BridgeAR
Copy link
Member

BridgeAR pushed a commit to BridgeAR/node that referenced this pull request May 18, 2018
In the document for fs, there are several functions that state "No
arguments other than a possible exception are given to the completion
callback." (ex> fs.access, fs.chmod, fs.close, ..)

But, the functions are invoking the callback with two parameters (err,
undefined)

It causes problems in using several API like
[async.waterfall](https://caolan.github.io/async/docs.html#waterfall).

PR-URL: nodejs#20629
Fixes: nodejs#20335
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@BridgeAR
Copy link
Member

Landed in 60cc8ff

@dankang congratulations on your first commit to Node.js! 🎉 You are now officially a contributor :-)

@BridgeAR BridgeAR closed this May 18, 2018
@dankang
Copy link
Contributor Author

dankang commented May 19, 2018

Thanks a lot! 👍

MylesBorins pushed a commit that referenced this pull request May 22, 2018
In the document for fs, there are several functions that state "No
arguments other than a possible exception are given to the completion
callback." (ex> fs.access, fs.chmod, fs.close, ..)

But, the functions are invoking the callback with two parameters (err,
undefined)

It causes problems in using several API like
[async.waterfall](https://caolan.github.io/async/docs.html#waterfall).

PR-URL: #20629
Fixes: #20335
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@addaleax addaleax mentioned this pull request May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node 10.0.0 fs.close is called with a second undefined argument.
6 participants