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

Please drop deprecated __proto__ calls #26

Closed
guimard opened this issue Sep 14, 2022 · 9 comments
Closed

Please drop deprecated __proto__ calls #26

guimard opened this issue Sep 14, 2022 · 9 comments

Comments

@guimard
Copy link

guimard commented Sep 14, 2022

Hi,

here is a simple patch to do this:

--- a/implementation.js
+++ b/implementation.js
@@ -4,7 +4,7 @@

 var isES5 = typeof Object.defineProperty === 'function';

-var hasProto = [].__proto__ === Array.prototype; // eslint-disable-line no-proto
+var hasProto = Object.getPrototypeOf([]) === Array.prototype

 if (!isES5 || !hasProto) {
        throw new TypeError('util.promisify requires a true ES5 environment, that also supports `__proto__`');
@@ -75,7 +75,7 @@
                });
        };

-       promisified.__proto__ = orig.__proto__; // eslint-disable-line no-proto
+       Object.setPrototypeOf(promisified, orig.__proto__);

        Object.defineProperty(promisified, kCustomPromisifiedSymbol, {
                configurable: true,
@ljharb
Copy link
Owner

ljharb commented Sep 14, 2022

Why? They aren't deprecated at all.

@guimard
Copy link
Author

guimard commented Sep 14, 2022

They are deprecated in Node.js and security teams recommends to launch Node.js with --disable-proto=throw

@guimard
Copy link
Author

guimard commented Sep 14, 2022

Facebook/jest accepted he same request: jestjs/jest#13256

@ljharb
Copy link
Owner

ljharb commented Sep 14, 2022

No, they are not deprecated in node.js - at all - but fair point that the --disable-proto flag might cause problems.

(I'm not motivated by what other projects do)

@ljharb
Copy link
Owner

ljharb commented Sep 14, 2022

I suppose I could detect when --disable-proto is used, and cache Object.getPrototypeOf in that case, but it adds some complexity for a rare and unadvisable use case.

@guimard
Copy link
Author

guimard commented Sep 14, 2022

It seems that for all supported Node.js, hasProto is always true

@guimard
Copy link
Author

guimard commented Sep 14, 2022

And Object.setPrototypeOf seems well supported

@ljharb
Copy link
Owner

ljharb commented Sep 14, 2022

I've written up an attempt here (https://github.com/ljharb/util.promisify/actions/runs/3050250295), but it's blocked by https://npmjs.com/graceful-fs.

@ljharb
Copy link
Owner

ljharb commented Apr 20, 2023

Turns out that only applies to nyc, so i can probably get this fixed.

@ljharb ljharb closed this as completed in 2e3c8b3 Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants