vscode 扩展:弃用警告 `Buffer()`,如何诊断 [英] vscode extension: deprecation warning `Buffer()`, how to diagnose
问题描述
我正在将我的评论荧光笔重建为一个新的
显然,如果你的扩展直接使用了 new Buffer()
你可以修复它.
如果您导入/需要一个使用 new Buffer()
的扩展,您有几个选择:寻找替代方案、将其分叉或向该存储库提交问题.
就我而言,以上都不是问题.您可以看到 fd-slicer
是问题所在.这是 yauzl 的依赖项.yauzl
由 vscode 本身使用,而不是由我或我的扩展程序的依赖项使用.
fd-slicer
上存在问题(维护者没有兴趣修复此问题,PR 修复) 和 yauzl
敦促切换到尚未合并的分叉 fd-slicer2
(PR 修复 - 考虑投票).在 vscode 上:缓冲区警告,yauzl.
我的节点版本:v15.9.0
对我来说,这个缓冲区警告目前只是一种刺激,幸运的是不会影响我的扩展程序的功能.
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:
- Windows 10
- Ubuntu 20 LTS
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.
Here are the steps I used to help diagnose what is causing that Buffer deprecation warning.
- Uninstall your extension. You may have to reload vscode after this.
- Terminal:
export NODE_OPTIONS=--throw-deprecation
- Terminal:
code-insiders --install-extension arturodent.find-and-transform
(orcode --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.
这篇关于vscode 扩展:弃用警告 `Buffer()`,如何诊断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!