Skip to content
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

"new Buffer() is deprecated" issue after compile with ncc #92

Open
dungwinux opened this issue Sep 22, 2019 · 8 comments
Open

"new Buffer() is deprecated" issue after compile with ncc #92

dungwinux opened this issue Sep 22, 2019 · 8 comments
Labels
bug Something isn't working

Comments

@dungwinux
Copy link
Member

After running ncc (powered by webpack), the output would include new Buffer(), which is deprecated since Node v10. As a result, Wafter would print warning out as error when starting server.

MIRAI Wafter 1.15.0+local
Copyright (c) 2018-2019 Vườn ươm A0. MIT License.
√ How can I help you ? · Start server
(node:3944) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

Wafter needs to either install polyfill or try to replace new Buffer() after running ncc.

@minhducsun2002
Copy link
Contributor

minhducsun2002 commented Oct 6, 2019

How about stopping using the constructor syntax altogether? After all, using it poses security risks.

If you wish to replace all new Buffer() calls, there is an ESLint rule for that - no-buffer-constructor.

@dungwinux
Copy link
Member Author

@minhducsun2002, the problem is, new Buffer() is a result after compiling using ncc.

@minhducsun2002
Copy link
Contributor

This should be reported to the ncc maintainers themselves.

@dungwinux
Copy link
Member Author

dungwinux commented Oct 8, 2019

Well, this is rather the result of using Webpack. Perhaps some modules has new Buffer() and Webpack has added all of those into code.

@dungwinux
Copy link
Member Author

dungwinux commented Oct 8, 2019

Regarding this, --zero-fill-buffers can be used to avoid the warning.
Update: command line invoke

pkg --options zero-fill-buffers -o dist/wafter .

Edit: This one doesn't work at all

@minhducsun2002
Copy link
Contributor

Try this : webpack/webpack#4240 (comment)

@minhducsun2002
Copy link
Contributor

minhducsun2002 commented Oct 8, 2019

Actually, the option above seems to be the solution for modules whose developers stepped away. We cannot control our (indirect) dependencies, and thus it seems to be the only way around this warning.

See this article.

@dungwinux
Copy link
Member Author

@minhducsun2002, ncc design goal is to have zero configuration, meaning there's noway you can configure the webpack bundled inside.

@dungwinux dungwinux added bug Something isn't working help wanted Extra attention is needed labels Oct 10, 2019
@dungwinux dungwinux pinned this issue Oct 13, 2019
@dungwinux dungwinux removed hacktoberfest help wanted Extra attention is needed labels Mar 8, 2020
@dungwinux dungwinux unpinned this issue Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants