-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Conversation
CI: https://ci.nodejs.org/job/node-test-pull-request/10911/ And since this modifies |
|
||
// Remove from the binding so that function is only available as exported here. | ||
// (That is, for internal use only.) | ||
delete binding.setupBufferJS; |
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.
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
node/lib/internal/bootstrap_node.js
Line 295 in 02a5267
global.Buffer = NativeModule.require('buffer').Buffer; |
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.
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;
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.
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');
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.
Cool, I'll throw a comment and explicit require in. Stay tuned.
17e4f98
to
a8aaaac
Compare
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.
a8aaaac
to
ecd7dc6
Compare
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.
LGTM with green CI
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/ |
CI failures are unrelated |
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>
Landed in 8172f45 |
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>
Should this be backported to |
@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 |
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>
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), orvcbuild test
(Windows) passesAffected core subsystem(s)
buffer