-
-
Save vdeturckheim/ef0e698803c75837b89df5c813eeea27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const CDP = require('chrome-remote-interface'); | |
const main = async function () { | |
const client = await CDP({ | |
port: 9229 | |
}); | |
await client.Runtime.enable(); | |
const ServerPrototypeResult = await client.Runtime.evaluate({expression:"require('http').Server.prototype", includeCommandLineAPI: true, returnByValue: false}); | |
const ServerInstanceListResult = await client.Runtime.queryObjects({ prototypeObjectId: ServerPrototypeResult.result.objectId }); | |
const ServerInstancesResult = await client.Runtime.getProperties({ objectId: ServerInstanceListResult.objects.objectId }); | |
const serverInstance = ServerInstancesResult.result[0].value.objectId; | |
await client.Runtime.evaluate({expression:"process.patchListeners = require(`./toInject.js`).patchListeners", includeCommandLineAPI: true, returnByValue: false}); | |
// in the injected function, the value for `this` will be the instance of the server | |
await client.Runtime.callFunctionOn({ objectId: serverInstance, functionDeclaration: 'function() { process.patchListeners(this) }', returnByValue: true }); | |
await client.Runtime.evaluate({expression:"delete process.patchListeners", includeCommandLineAPI: true, returnByValue: false}); | |
await client.Runtime.evaluate({"expression":"require('inspector').close()","includeCommandLineAPI":true}); | |
await client.close(); | |
}; | |
main(); // on Node 15, an error will stop the process |
can you tell me your node version?
Did you make sure the other process has its debug port open on 9229? The node version should not have impact for anything fairly recent.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi,I try the demo on a centos system,but it can't print GET info .Is there any other configuration here.