Skip to content

Commit

Permalink
inspector: refactor inspector/promises to be more robust
Browse files Browse the repository at this point in the history
Limit the effect of users mutating `node:util`, `node:inspector`, or
`Array.prototype`.

PR-URL: #45041
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
aduh95 authored and RafaelGSS committed Nov 10, 2022
1 parent 2e5d8e7 commit 3db37e7
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/inspector/promises.js
Original file line number Diff line number Diff line change
@@ -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<unknown, unknown>} [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,
Expand Down

0 comments on commit 3db37e7

Please sign in to comment.