Skip to content

Commit 3db37e7

Browse files
aduh95RafaelGSS
authored andcommitted
inspector: refactor inspector/promises to be more robust
Limit the effect of users mutating `node:util`, `node:inspector`, or `Array.prototype`. PR-URL: #45041 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 2e5d8e7 commit 3db37e7

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

lib/inspector/promises.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
'use strict';
22

33
const inspector = require('inspector');
4-
const { promisify } = require('util');
5-
const { FunctionPrototypeBind } = primordials;
4+
const { promisify } = require('internal/util');
5+
66
class Session extends inspector.Session {
7-
#post = promisify(FunctionPrototypeBind(super.post, this));
8-
/**
9-
* Posts a message to the inspector back-end.
10-
* @param {string} method
11-
* @param {Record<unknown, unknown>} [params]
12-
* @returns {Promise}
13-
*/
14-
async post(method, params) {
15-
return this.#post(method, params);
16-
}
7+
constructor() { super(); } // eslint-disable-line no-useless-constructor
178
}
9+
Session.prototype.post = promisify(inspector.Session.prototype.post);
1810

1911
module.exports = {
2012
...inspector,

0 commit comments

Comments
 (0)