From e79b9a80cf8d4dd867eb0973715676769b8275c4 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 17 Oct 2022 16:20:56 +0200 Subject: [PATCH] inspector: refactor `inspector/promises` to be more robust Limit the effect of users mutating `node:util`, `node:inspector`, or `Array.prototype`. --- 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,