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 <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
aduh95 authored and RafaelGSS committed Nov 1, 2022
1 parent 4f7f228 commit 6f6a8ce
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 6f6a8ce

Please sign in to comment.