I am rebuilding my comment highlighter in to a new extension.
However I now run now in to an issue where I get the following warning:
(node:4904) [DEP0005] DeprecationWarning:
Buffer() is deprecated due to security and usability issues.
Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
So far I can find in my extension I never use the function Buffer()
I think that it comes from the vscode
module.
When the warning occurs block comment highlighting stops working.
This issue is breaking for my extension in development mode.
However my old extension has the same issue in development mode and released version.
Only in the released version doesn't report of the warning.
I am sorry for not including a minimal, reproducible example.
UPDATE:
In the latest release of my comment highlighter I have fixed block comment highlighting. At least I have fixed what was broken on my end.
The (node:4904) [DEP0005] DeprecationWarning
keeps breaking my extension on rare occasions, this happens in all my environments.
Restarting vscode or rebooting the operating system can sometimes fix it. I have noticed that other extensions break as well when my extension is broken.
Operating systems I run:
On both OSes I run nvm to manage node and npm versions. I currently have 2 computers both dual booted with the named OSes The issue occurs on both computers.
You can click on the summary or press Ctrl+Shift+M to display the PROBLEMS panel with a list of all current errors. If you open a file that has errors or warnings, they will be rendered inline with the text and in the overview ruler.
The solution was to go to Windows PowerShell and open Visual Studio Code, then go to the extensions and restart the Remote - WSL extension, and go back to WSL. It then started working immediately.
[error] [Extension Host] (node:61654) [DEP0005] DeprecationWarning: Buffer () is deprecated due to security and usability issues. Please use the Buffer.alloc (), Buffer.allocUnsafe (), or Buffer.from () methods instead.
For me, this Buffer warning is currently an irritant only, and does not affect the functionality of my extension fortunately. Show activity on this post. I encountered a somewhat similar incident while trying to create my first extension.
Obviously, if your extension directly used new Buffer () you can fix it. If you imported/required an extension that uses new Buffer () you have a couple of options: look for an alternative, fork it or file an issue with that repository. In my case, neither of the above was the issue.
The use of the deprecated new Buffer() constructor (i.E. as used by Yarn) can cause deprecation warnings. Therefore one should NOT use the deprecated/unsafe Buffer constructor. According to the deprecation warning new Buffer() should be replaced with one of: Another option in order to avoid this issue would be using the safe-buffer package instead.
Here are the steps I used to help diagnose what is causing that Buffer deprecation warning.
export NODE_OPTIONS=--throw-deprecation
code-insiders --install-extension arturodent.find-and-transform
code --install-extension arturodent.find-and-transform
if not on Insiders)(replace with your extension id found in the package.json)
That should re-install the extension with a stack trace about the deprecation warning.
Obviously, if your extension directly used new Buffer()
you can fix it.
If you imported/required an extension that uses new Buffer()
you have a couple of options: look for an alternative, fork it or file an issue with that repository.
In my case, neither of the above was the issue. You can see that fd-slicer
is the problem. And that is a dependency of yauzl. yauzl
is used by vscode itself, not by me or by my extension's dependencies.
There are issues filed on fd-slicer
(maintainer has no interest in fixing this, PR to fix) and on yauzl
urging to switch to a forked fd-slicer2
which hasn't been merged yet (PR to fix - consider upvoting). And on vscode: buffer warning, yauzl.
My node version: v15.9.0
For me, this Buffer warning is currently an irritant only, and does not affect the functionality of my extension fortunately.
I encountered a somewhat similar incident while trying to create my first extension. So launching the Command Palette - Ctrl
+ Shift
+ P
and selecting >Developer: Reload Window
helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With