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

buffer: move setupBufferJS to internal #16391

Closed
wants to merge 1 commit into from

Conversation

bengl
Copy link
Member

@bengl bengl commented Oct 22, 2017

Stashing it away in internal/buffer so that it can't be used in userland, but can still be used in internals.

/cc @Fishrock123 @addaleax since we've previously talked about doing this.

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

buffer

@nodejs-github-bot nodejs-github-bot added the buffer Issues and PRs related to the buffer subsystem. label Oct 22, 2017
@bengl
Copy link
Member Author

bengl commented Oct 22, 2017

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

And since this modifies process.binding('buffer'), CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1025/


// Remove from the binding so that function is only available as exported here.
// (That is, for internal use only.)
delete binding.setupBufferJS;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not blocking, and up for debate:
Since this changes global state, maybe move this to node_bootstap, or explicitly require with a comment. Otherwise AFAICT it will run as a side effect of

global.Buffer = NativeModule.require('buffer').Buffer;
which is not obvius

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I'd like to keep the caching and removing of setupBufferJS in the same place. Would a comment in bootstrap_node.js clarifying that requiring buffer also removes the setupBufferJS from the binding be sufficient to clarify? Something like:

// Note that this requires `lib/internal/buffer.js`, which removes `setupBufferJS`
// from the buffer binding.
global.Buffer = NativeModule.require('buffer').Buffer;

Copy link
Contributor

Choose a reason for hiding this comment

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

Another viable option is to add this to bootstrap_node.js

// This require as side effect removes `setupBufferJS` from the buffer binding.
NativeModule.require('internal/buffer.js');

Copy link
Member Author

@bengl bengl Oct 22, 2017

Choose a reason for hiding this comment

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

Cool, I'll throw a comment and explicit require in. Stay tuned.

@bengl
Copy link
Member Author

bengl commented Oct 22, 2017

I've just realized the commit message is wrong. Fixing it now.

Stashing it away in internal/buffer so that it can't be used in
userland, but can still be used in internals.
@bengl bengl changed the title buffer: move setupBindingJS to internal buffer: move setupBufferJS to internal Oct 22, 2017
Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

LGTM with green CI

@bengl
Copy link
Member Author

bengl commented Oct 25, 2017

Alright here's another round of CI and CITGM, since this has changed slightly as per @refack's review.

CI: https://ci.nodejs.org/job/node-test-pull-request/10955/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1028/

@jasnell
Copy link
Member

jasnell commented Oct 25, 2017

CI failures are unrelated

jasnell pushed a commit that referenced this pull request Oct 25, 2017
Stashing it away in internal/buffer so that it can't be used in
userland, but can still be used in internals.

PR-URL: #16391
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell
Copy link
Member

jasnell commented Oct 25, 2017

Landed in 8172f45

@jasnell jasnell closed this Oct 25, 2017
addaleax pushed a commit to ayojs/ayo that referenced this pull request Oct 26, 2017
Stashing it away in internal/buffer so that it can't be used in
userland, but can still be used in internals.

PR-URL: nodejs/node#16391
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@gibfahn
Copy link
Member

gibfahn commented Oct 30, 2017

Should this be backported to v8.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

@bengl
Copy link
Member Author

bengl commented Nov 4, 2017

@gibfahn I think in order to avoid the circular dependency issue (https://github.com/nodejs/node/blob/v8.x-staging/lib/buffer.js#L1501-L1503) (not an issue on master/9.x) it may not make sense to backport this commit as it's implemented. That is, putting setupBufferJS into internal/buffer might not make sense on 8.x.

addaleax pushed a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
Stashing it away in internal/buffer so that it can't be used in
userland, but can still be used in internals.

PR-URL: nodejs/node#16391
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants