-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: hard-deprecate SlowBuffer #8182
Conversation
This emits a warning first time SlowBuffer instance is created and instructs the users to switch to Buffer.alloc() or Buffer.allocUnsafeSlow(), both of which are not pooled. Refs: nodejs#8169 Refs: nodejs#7152
If we aren't hard-deprecating Buffer constructor in v7.0 due to v0.12 support, then the same reasoning should apply here. I don't think the number of users should be the deciding factor. |
@seishun That is true, but the difference here is that In v0.12 it got properly documented, though: https://nodejs.org/docs/latest-v0.12.x/api/buffer.html#buffer_class_slowbuffer |
slowBufferWarned = true; | ||
process.emitWarning( | ||
'SlowBuffer is deprecated. ' + | ||
'Use `Buffer.alloc()` or `Buffer.allocUnsafeSlow()` instead.' |
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.
This would need a second argument set to 'DeprecationWarning'
... that is:
process.emitWarning(
'SlowBuffer is deprecated. ' +
'Use `Buffer.alloc()` or `Buffer.allocUnsafeSlow()` instead.',
'DeprecationWarning');
this would also need a test case verifying that the deprecation warning was emitted. |
Since require('buffer').SlowBuffer = Buffer.unsafeAllocSlow; |
c133999
to
83c7a88
Compare
This should probably be paired with #7152, so targeting 8.0 likewise. |
This won't happen soon, afaik. |
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
buffer
Description of change
This emits a warning first time
SlowBuffer
instance is created and instructs the users to switch toBuffer.alloc()
orBuffer.allocUnsafeSlow()
, both of which are not pooled.Refs: #8169
Refs: #7152
Not sure if we should do this in v7 or v8. It looks like SlowBuffer is used only by a small number of modules (I found 416, only 330 of which — outside of tests, and some of those are false positives). Module authors could use safe-buffer to polyfill for older Node.js versions, though.
Labelling as
in progress
because this lacks tests./cc @nodejs/ctc, @seishun