-
Notifications
You must be signed in to change notification settings - Fork 7.3k
assigning Buffer in repl throws error #8588
Comments
cc/ @chrisdickinson |
I've dug through the source. This is because 'isBuffer' was declared as a static method for Buffer, and never exposed, this is on https://github.com/joyent/node/blob/v0.10.32-release/lib/buffer.js#L277 and yet in the newer releases, util.isBuffer is being used inside _stream_writable.js for that check. Any thoughts on exposing this method or better conforming to the new usage of util.isBuffer? |
This is happening because we are using
cc @trevnorris |
Overriding a documented global is going to lead to issues. Not sure I'd consider this a bug. That being said, I'd okay a patch either replacing |
Roger that. However, doing explicit requires in each of those file won't remedy the name conflict with the global object 'Buffer'. |
@odeke-em I think that we should follow the way that I have proposed :) |
Thank you folks for the good tips. @indutny, kuddos -- I've been able to test this out in code with no more fails, PR with your solution coming up in a few. In deed global objects should not be used in lib/*. |
Fixes usage of global object 'Buffer' in lib/* files by ensuring that each file does an explicit require('buffer').Buffer. Previously, when running a repl, due to usage of global 'Buffer', any redefinition of Buffer would cause a crash eg var Buffer = {}. Fixes: #8588 PR-URL: #8603 Reviewed-by: Trevor Norris <[email protected]>
Fixed by 523929c. |
Fixes usage of global object 'Buffer' in lib/* files by ensuring that each file does an explicit require('buffer').Buffer. Previously, when running a repl, due to usage of global 'Buffer', any redefinition of Buffer would cause a crash eg var Buffer = {}. Fixes: nodejs#8588 PR-URL: nodejs#8603 Reviewed-by: Trevor Norris <[email protected]>
Fixes usage of global object 'Buffer' in lib/* files by ensuring that each file does an explicit require('buffer').Buffer. Previously, when running a repl, due to usage of global 'Buffer', any redefinition of Buffer would cause a crash eg var Buffer = {}. Fixes: nodejs/node-v0.x-archive#8588 PR-URL: nodejs/node-v0.x-archive#8603 Reviewed-by: Trevor Norris <[email protected]> Conflicts: lib/_stream_readable.js lib/_stream_writable.js lib/assert.js lib/dgram.js lib/fs.js lib/http.js lib/net.js lib/readline.js lib/tls.js lib/zlib.js
in a repl if I do
I get this error
I understand that core modules are included in repl globally, But this behavior seems wrong.
v.0.10.32
The text was updated successfully, but these errors were encountered: