question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A little background:

Now, what are we going to do moving forward? Using new Buffer() emits a deprecation warning in Node v7.0.0-v7.2.1.

I’m wondering if we shouldn’t consider some sort of fallback solution.


Also, this brings up the security question that prompted Node to change the Buffer API in the first place: new Buffer returns an uninitialized buffer. Currently, we are not zero-filling it. I can’t see how this could be exploited in the current implementation, but it would be good to have this reviewed.

If we do not need the buffer to be initialized, we should use Buffer.allocUnsafe, not Buffer.alloc, in later versions.

Atten: @jprichardson @manidlou @dr-dimitru

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jprichardsoncommented, Mar 16, 2017

@RyanZim good point. Let’s just go with allocUnsafe()

@dr-dimitru looks good!

0reactions
dr-dimitrucommented, Mar 16, 2017

Hi @jprichardson

Here is my snipped from #380 thread:

var _buffer = {
  allocUnsafe: function (len) {
    if (typeof Buffer.allocUnsafe === 'function') {
      try {
        // Node 4.4.* Buffer.allocUnsafe already exists, but throws exception in edge cases
        return Buffer.allocUnsafe(len);
      } catch (_error) {
        return new Buffer(len);
      }
    }
    return new Buffer(len);
  }
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Which of the following is correct regarding buffer solution?
Which of the following is correct regarding buffer solution? A. It contains weak acid and its conjugate base. B ...
Read more >
17.2: Buffer Solutions - Chemistry LibreTexts
Buffers are solutions that maintain a relatively constant pH when an acid ... For buffer concentrations of at least 0.500 M, the addition...
Read more >
Buffer solution - Wikipedia
A buffer solution is an aqueous solution consisting of a mixture of a weak acid and its ... In nature, there are many...
Read more >
A buffer is a solution that resists changes in pH upon the ...
A buffer is composed of a mixture·of a weak acid its conjugate base. ... (Note: For a buffer to resist changes in pH,...
Read more >
Buffer: All-you-need social media toolkit for small businesses
Buffer helps you build an audience organically. We're a values-driven company that provides affordable, intuitive, marketing tools for ambitious people and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found