From 6f6a8ce21b790049683a319592952d62bf934d6d Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 19 Oct 2022 13:39:31 -0500 Subject: [PATCH] inspector: refactor `inspector/promises` to be more robust Limit the effect of users mutating `node:util`, `node:inspector`, or `Array.prototype`. PR-URL: https://github.com/nodejs/node/pull/45041 Reviewed-By: Yagiz Nizipli Reviewed-By: Moshe Atlow Reviewed-By: James M Snell --- lib/inspector/promises.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/inspector/promises.js b/lib/inspector/promises.js index cd13a2ea2d5126..462941f1d5b597 100644 --- a/lib/inspector/promises.js +++ b/lib/inspector/promises.js @@ -1,20 +1,12 @@ 'use strict'; const inspector = require('inspector'); -const { promisify } = require('util'); -const { FunctionPrototypeBind } = primordials; +const { promisify } = require('internal/util'); + class Session extends inspector.Session { - #post = promisify(FunctionPrototypeBind(super.post, this)); - /** - * Posts a message to the inspector back-end. - * @param {string} method - * @param {Record} [params] - * @returns {Promise} - */ - async post(method, params) { - return this.#post(method, params); - } + constructor() { super(); } // eslint-disable-line no-useless-constructor } +Session.prototype.post = promisify(inspector.Session.prototype.post); module.exports = { ...inspector,