Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
inspector: added --inspect-publish-uid
This flag specifies how inspector websocket url should be reported.
Tthre options are supported:
- stderr - reports websocket as a message to stderr,
- http - exposes /json/list endpoint that contains inspector websocket
url,
- binding - require('inspector').url().
Related discussion: nodejs/diagnostics#303
PR-URL: #27741
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>- Loading branch information
Showing
with
148 additions
and 22 deletions.
- +8 −0 doc/api/cli.md
- +4 −1 src/inspector_agent.cc
- +11 −4 src/inspector_io.cc
- +5 −2 src/inspector_io.h
- +41 −14 src/inspector_socket_server.cc
- +2 −0 src/inspector_socket_server.h
- +21 −0 src/node_options.cc
- +9 −0 src/node_options.h
- +5 −1 test/cctest/test_inspector_socket_server.cc
- +42 −0 test/parallel/test-inspect-publish-uid.js
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
| @@ -0,0 +1,42 @@ | ||
| 'use strict'; | ||
| const common = require('../common'); | ||
|
|
||
| common.skipIfInspectorDisabled(); | ||
|
|
||
| const assert = require('assert'); | ||
| const { spawnSync } = require('child_process'); | ||
|
|
||
| (async function test() { | ||
| await testArg('stderr'); | ||
| await testArg('http'); | ||
| await testArg('http,stderr'); | ||
| })(); | ||
|
|
||
| async function testArg(argValue) { | ||
| console.log('Checks ' + argValue + '..'); | ||
| const hasHttp = argValue.split(',').includes('http'); | ||
| const hasStderr = argValue.split(',').includes('stderr'); | ||
|
|
||
| const nodeProcess = spawnSync(process.execPath, [ | ||
| '--inspect=0', | ||
| `--inspect-publish-uid=${argValue}`, | ||
| '-e', `(${scriptMain.toString()})(${hasHttp ? 200 : 404})` | ||
| ]); | ||
| const hasWebSocketInStderr = checkStdError( | ||
| nodeProcess.stderr.toString('utf8')); | ||
| assert.strictEqual(hasWebSocketInStderr, hasStderr); | ||
|
|
||
| function checkStdError(data) { | ||
| const matches = data.toString('utf8').match(/ws:\/\/.+:(\d+)\/.+/); | ||
| return !!matches; | ||
| } | ||
|
|
||
| function scriptMain(code) { | ||
| const url = require('inspector').url(); | ||
| const { host } = require('url').parse(url); | ||
| require('http').get('http://' + host + '/json/list', (response) => { | ||
| assert.strictEqual(response.statusCode, code); | ||
| response.destroy(); | ||
| }); | ||
| } | ||
| } |