GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: simplify the error context collection in C++, migrate fs.close errors by joyeecheung · Pull Request #17338 · nodejs/node

Conversation

@joyeecheung

@joyeecheung joyeecheung commented Nov 27, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

fs: simplify the error context collection in C++

  • Simplify the SyncCall template function, only collect error
    number and syscall in the C++ layer and collect the rest of context
    in JS for flexibility.
  • Remove the stringFromPath JS helper now that the unprefixed path is
    directly put into the context before the binding is invoked with the
    prefixed path.
  • Add a errno -> [error code, uv error message] map to the uv binding
    so the error message can be assembled in the JS layer

fs: throw fs.close errors in JS

  • Check fd in JS before invoking the binding and throw
    ERR_INVALID_ARG_TYPE if it's not an integer
  • Add a test for checking the errors thrown from fs.close and
    fs.closeSync
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

fs, test, errors

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. labels Nov 27, 2017
@joyeecheung
joyeecheung force-pushed the fs-error-close branch from 6045b01 to 00e4029 Compare November 27, 2017 04:28
@joyeecheung joyeecheung changed the title fs: simply the error context collection in C++, migrate fs.close errors fs: simplify the error context collection in C++, migrate fs.close errors Nov 27, 2017
joyeecheung
joyeecheung commented Nov 27, 2017
View reviewed changes
Comment thread test/parallel/test-fs-close-error.js Outdated

@joyeecheung joyeecheung Nov 27, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The current error does not include any information about the fd being closed (I think it's also the same for other fs APIs that takes fd as arguments). To improve this properly we would need to update the After callback so that async APIs can be consistent with the synchronous APIs. We could add fd as an argument to UVException but IMO that's just going to bloat the signature of that function even further, putting those data in an object in JS is much more flexible.

Since After is also used by functions not migrated yet, I would like to update this bit when all the fs errors are migrated to the JS layer.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@joyeecheung

joyeecheung commented Nov 27, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/11741/
CI: https://ci.nodejs.org/job/node-test-pull-request/11742/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung
joyeecheung force-pushed the fs-error-close branch from 00e4029 to 7f3f9d9 Compare November 27, 2017 04:49
@joyeecheung joyeecheung added fs Issues and PRs related to file-system APIs and the fs module. semver-major PRs that contain breaking changes and should be released in the next major version. labels Nov 27, 2017
@jasnell

jasnell commented Nov 27, 2017

Copy link
Copy Markdown
Member

Slight bit of overlap with this: #17334

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Nov 27, 2017

Copy link
Copy Markdown
Member

@joyeecheung ... in #17334 I'm going to be focusing entirely on moving the input arg validation out into javascript. To make it easier on us both, how about focusing this PR only on the other errors then we can meet in the middle :-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Nov 28, 2017

Copy link
Copy Markdown
Member Author

@jasnell ACK, thanks, I only migrated those type checks in this PR as well because since I was migrating fs.close, might as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung
joyeecheung force-pushed the fs-error-close branch from 7f3f9d9 to 0309a8a Compare November 29, 2017 10:04
@joyeecheung

joyeecheung commented Nov 29, 2017

Copy link
Copy Markdown
Member Author

Removed the type checks in favor of #17334

CI: https://ci.nodejs.org/job/node-test-pull-request/11797/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Nov 30, 2017

Copy link
Copy Markdown
Member Author

CI is green minus a jenkins failure. Marking this semver-major because it depends on #17160 , although I think both could be backported to v8.x if we skip the type check part..

@jasnell @fhinkel @nodejs/tsc PTAL, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Dec 5, 2017
View reviewed changes
@joyeecheung joyeecheung added dont-land-on-v4.x and removed semver-major PRs that contain breaking changes and should be released in the next major version. labels Dec 5, 2017
@joyeecheung

joyeecheung commented Dec 5, 2017

Copy link
Copy Markdown
Member Author

This is no longer semver major, but defensively adding the don't land labels until #17160 is backported in non-semver-major fashion

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins
MylesBorins force-pushed the master branch from b7405ab to 7f086dd Compare December 8, 2017 16:37
@addaleax addaleax added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Dec 10, 2017
BridgeAR
BridgeAR reviewed Dec 12, 2017
View reviewed changes
Comment thread lib/internal/errors.js Outdated

@BridgeAR BridgeAR Dec 12, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The message will actually not show up because it should be non-enumerable. If ctx is a regular error.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@BridgeAR BridgeAR Dec 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Ignore me, I should have checked what ctx stands for. When I commented first it seemed like a error.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
BridgeAR
BridgeAR reviewed Dec 12, 2017
View reviewed changes
Comment thread lib/internal/errors.js Outdated

@BridgeAR BridgeAR Dec 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think you wanted to write ctx[prop] instead of ctx.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
BridgeAR
BridgeAR approved these changes Dec 12, 2017
View reviewed changes

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

JS part LGTM besides the comment. The rest is also LG as far as I can tell.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BridgeAR BridgeAR removed the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Dec 12, 2017
@joyeecheung
joyeecheung force-pushed the fs-error-close branch from 0309a8a to 4fcf4ee Compare December 16, 2017 09:25
@joyeecheung

joyeecheung commented Dec 16, 2017

Copy link
Copy Markdown
Member Author

Rebased now that the type checking tests have landed. Also validate the syscall and errno properties to avoid the mistakes as @BridgeAR pointed out. New CI: https://ci.nodejs.org/job/node-test-pull-request/12148/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung removed the wip Issues and PRs that are still a work in progress. label Dec 26, 2017
@joyeecheung

joyeecheung commented Dec 27, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-commit/15076/

Minimized the changes to node_file.cc and split the uv binding changes to a separate commit. CI is green now minus one unrelated failure. @jasnell @BridgeAR PTAL.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Dec 27, 2017

Copy link
Copy Markdown
Member

still lgtm

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Dec 27, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Landed in 24c71fb...9f122e3, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung closed this Dec 27, 2017
joyeecheung added a commit that referenced this pull request Dec 27, 2017
@joyeecheung
src: expose uv.errmap to binding
c569727
Add a errno -> [error code, uv error message] map to the uv binding
so the error message can be assembled in the JS layer.

PR-URL: #17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
joyeecheung added a commit that referenced this pull request Dec 27, 2017
@joyeecheung
fs: simplify the error context collection in C++
6ca10de
- Simplify the SyncCall template function, only collect error
  number and syscall in the C++ layer and collect the rest of context
  in JS for flexibility.
- Remove the stringFromPath JS helper now that the unprefixed path is
  directly put into the context before the binding is invoked with the
  prefixed path.
- Validate more properties in fs.access tests.

PR-URL: #17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
joyeecheung added a commit that referenced this pull request Dec 27, 2017
@joyeecheung
fs: throw fs.close errors in JS
9f122e3
* Collect the error context in both JS and C++, then throw
  the error in JS
* Test that the errors thrown from fs.close and fs.closeSync
  includes the correct error code, error number and syscall
  properties

PR-URL: #17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@joyeecheung joyeecheung mentioned this pull request Jan 9, 2018
test: zlib-binding.deflate flaky v8/node#45
Closed
@joyeecheung joyeecheung mentioned this pull request Feb 21, 2018
[v9.x] backport 17338, 18186, 18358, 18546 #18916
Closed
joyeecheung added a commit to joyeecheung/node that referenced this pull request Feb 22, 2018
@joyeecheung
src: expose uv.errmap to binding
017013a
Add a errno -> [error code, uv error message] map to the uv binding
so the error message can be assembled in the JS layer.

PR-URL: nodejs#17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
MylesBorins pushed a commit that referenced this pull request Feb 26, 2018
@joyeecheung @MylesBorins
src: expose uv.errmap to binding
a92a359
Add a errno -> [error code, uv error message] map to the uv binding
so the error message can be assembled in the JS layer.

Backport-PR-URL: #18916
PR-URL: #17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
MylesBorins pushed a commit that referenced this pull request Feb 26, 2018
@joyeecheung @MylesBorins
src: expose uv.errmap to binding
4de4c54
Add a errno -> [error code, uv error message] map to the uv binding
so the error message can be assembled in the JS layer.

Backport-PR-URL: #18916
PR-URL: #17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@addaleax addaleax mentioned this pull request Feb 27, 2018
v9.7.0 proposal #19040
Closed
@joyeecheung joyeecheung mentioned this pull request Mar 7, 2018
[v8.x backport] backport 17338, 18186, 18358, 18546 #19191
Closed
joyeecheung added a commit to joyeecheung/node that referenced this pull request May 2, 2018
@joyeecheung
src: expose uv.errmap to binding
1f35b8f
Add a errno -> [error code, uv error message] map to the uv binding
so the error message can be assembled in the JS layer.

PR-URL: nodejs#17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
MylesBorins pushed a commit that referenced this pull request May 22, 2018
@joyeecheung @MylesBorins
src: expose uv.errmap to binding
3a7ad60
Add a errno -> [error code, uv error message] map to the uv binding
so the error message can be assembled in the JS layer.

Backport-PR-URL: #19191
PR-URL: #17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 14, 2018
@joyeecheung @MylesBorins
src: expose uv.errmap to binding
788fb29
Add a errno -> [error code, uv error message] map to the uv binding
so the error message can be assembled in the JS layer.

Backport-PR-URL: #19191
PR-URL: #17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jul 9, 2018
v8.12.0 proposal #21593
Merged
rvagg pushed a commit that referenced this pull request Aug 16, 2018
@joyeecheung @rvagg
src: expose uv.errmap to binding
c39b002
Add a errno -> [error code, uv error message] map to the uv binding
so the error message can be assembled in the JS layer.

Backport-PR-URL: #19191
PR-URL: #17338
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@BridgeAR BridgeAR BridgeAR approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. errors Issues and PRs related to JavaScript errors originating in Node.js core. fs Issues and PRs related to file-system APIs and the fs module. lib / src Issues and PRs involving general changes in the lib/ or src/ directories.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@joyeecheung @jasnell @BridgeAR @addaleax @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.