From 9926b89a9939cad01abd5bc5f5975e3bd655895b 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 cd13a2ea2d5..462941f1d5b 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,