Skip to content

buffer: move setupBufferJS to internal - #16391

Closed
bengl wants to merge 1 commit into
nodejs:masterfrom
bengl:bengl/bufferbindingfix
Closed

buffer: move setupBufferJS to internal#16391
bengl wants to merge 1 commit into
nodejs:masterfrom
bengl:bengl/bufferbindingfix

Conversation

@bengl

Copy link
Copy Markdown
Member

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-botnodejs-github-bot added the buffer Issues and PRs related to the buffer subsystem. label Oct 22, 2017
@bengl

bengl commented Oct 22, 2017

Copy link
Copy Markdown
MemberAuthor

Comment threadlib/internal/buffer.js Outdated

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
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');

@benglbenglOct 22, 2017

Copy link
Copy Markdown
MemberAuthor

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
benglforce-pushed the bengl/bufferbindingfix branch from 17e4f98 to a8aaaacCompareOctober 22, 2017 23:01
@bengl

Copy link
Copy Markdown
MemberAuthor

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
benglforce-pushed the bengl/bufferbindingfix branch from a8aaaac to ecd7dc6CompareOctober 22, 2017 23:11
@benglbengl changed the title buffer: move setupBindingJS to internalbuffer: move setupBufferJS to internalOct 22, 2017

@jasnelljasnell left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Member

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
Copy Markdown
Member

Landed in 8172f45

@jasnelljasnell 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
Copy Markdown
Member

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

bengl commented Nov 4, 2017

Copy link
Copy Markdown
MemberAuthor

@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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bufferIssues and PRs related to the buffer subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@bengl@jasnell@gibfahn@refack@addaleax@TimothyGu@cjihrig@MylesBorins@nodejs-github-bot