| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b2e6048 commit 824dcfc
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -370,7 +370,6 @@ Environment* CreateEnvironment( | |||
| 370 | 370 | Environment* env = new Environment( | |
| 371 | 371 | isolate_data, context, args, exec_args, nullptr, flags, thread_id); | |
| 372 | 372 | #if HAVE_INSPECTOR | |
| 373 | - // TODO(joyeecheung): handle the exit code returned by InitializeInspector(). | ||
| 374 | 373 | if (env->should_create_inspector()) { | |
| 375 | 374 | if (inspector_parent_handle) { | |
| 376 | 375 | env->InitializeInspector( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -617,7 +617,7 @@ class Environment : public MemoryRetainer { | |||
| 617 | 617 | #if HAVE_INSPECTOR | |
| 618 | 618 | // If the environment is created for a worker, pass parent_handle and | |
| 619 | 619 | // the ownership if transferred into the Environment. | |
| 620 | - ExitCode InitializeInspector( | ||
| 620 | + void InitializeInspector( | ||
| 621 | 621 | std::unique_ptr<inspector::ParentInspectorHandle> parent_handle); | |
| 622 | 622 | #endif | |
| 623 | 623 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -166,7 +166,7 @@ void SignalExit(int signo, siginfo_t* info, void* ucontext) { | |||
| 166 | 166 | #endif // __POSIX__ | |
| 167 | 167 | ||
| 168 | 168 | #if HAVE_INSPECTOR | |
| 169 | - ExitCode Environment::InitializeInspector( | ||
| 169 | + void Environment::InitializeInspector( | ||
| 170 | 170 | std::unique_ptr<inspector::ParentInspectorHandle> parent_handle) { | |
| 171 | 171 | std::string inspector_path; | |
| 172 | 172 | bool is_main = !parent_handle; | |
@@ -187,7 +187,7 @@ ExitCode Environment::InitializeInspector( | |||
| 187 | 187 | is_main); | |
| 188 | 188 | if (options_->debug_options().inspector_enabled && | |
| 189 | 189 | !inspector_agent_->IsListening()) { | |
| 190 | - return ExitCode::kInvalidCommandLineArgument2; // Signal internal error | ||
| 190 | + return; | ||
| 191 | 191 | } | |
| 192 | 192 | ||
| 193 | 193 | profiler::StartProfilers(this); | |
@@ -196,7 +196,7 @@ ExitCode Environment::InitializeInspector( | |||
| 196 | 196 | inspector_agent_->PauseOnNextJavascriptStatement("Break at bootstrap"); | |
| 197 | 197 | } | |
| 198 | 198 | ||
| 199 | - return ExitCode::kNoFailure; | ||
| 199 | + return; | ||
| 200 | 200 | } | |
| 201 | 201 | #endif // HAVE_INSPECTOR | |
| 202 | 202 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,8 +181,6 @@ NodeMainInstance::CreateMainEnvironment(ExitCode* exit_code) { | |||
| 181 | 181 | SetIsolateErrorHandlers(isolate_, {}); | |
| 182 | 182 | env->InitializeMainContext(context, &(snapshot_data_->env_info)); | |
| 183 | 183 | #if HAVE_INSPECTOR | |
| 184 | - // TODO(joyeecheung): handle the exit code returned by | ||
| 185 | - // InitializeInspector(). | ||
| 186 | 184 | env->InitializeInspector({}); | |
| 187 | 185 | #endif | |
| 188 | 186 | ||
@@ -201,8 +199,6 @@ NodeMainInstance::CreateMainEnvironment(ExitCode* exit_code) { | |||
| 201 | 199 | EnvironmentFlags::kDefaultFlags, | |
| 202 | 200 | {})); | |
| 203 | 201 | #if HAVE_INSPECTOR | |
| 204 | - // TODO(joyeecheung): handle the exit code returned by | ||
| 205 | - // InitializeInspector(). | ||
| 206 | 202 | env->InitializeInspector({}); | |
| 207 | 203 | #endif | |
| 208 | 204 | if (env->principal_realm()->RunBootstrapping().IsEmpty()) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1173,8 +1173,6 @@ ExitCode SnapshotBuilder::Generate(SnapshotData* out, | |||
| 1173 | 1173 | // in the future). | |
| 1174 | 1174 | if (snapshot_type == SnapshotMetadata::Type::kFullyCustomized) { | |
| 1175 | 1175 | #if HAVE_INSPECTOR | |
| 1176 | - // TODO(joyeecheung): handle the exit code returned by | ||
| 1177 | - // InitializeInspector(). | ||
| 1178 | 1176 | env->InitializeInspector({}); | |
| 1179 | 1177 | #endif | |
| 1180 | 1178 | if (LoadEnvironment(env, StartExecutionCallback{}).IsEmpty()) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,59 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + common.skipIfInspectorDisabled(); | ||
| 4 | + | ||
| 5 | + const { spawnSync } = require('child_process'); | ||
| 6 | + const { createServer } = require('http'); | ||
| 7 | + const assert = require('assert'); | ||
| 8 | + const fixtures = require('../common/fixtures'); | ||
| 9 | + const entry = fixtures.path('empty.js'); | ||
| 10 | + const { Worker } = require('worker_threads'); | ||
| 11 | + | ||
| 12 | + function testOnServerListen(fn) { | ||
| 13 | + const server = createServer((socket) => { | ||
| 14 | + socket.end('echo'); | ||
| 15 | + }); | ||
| 16 | + | ||
| 17 | + server.on('listening', () => { | ||
| 18 | + fn(server); | ||
| 19 | + server.close(); | ||
| 20 | + }); | ||
| 21 | + server.listen(0, '127.0.0.1'); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + function testChildProcess(getArgs, exitCode) { | ||
| 25 | + testOnServerListen((server) => { | ||
| 26 | + const { port } = server.address(); | ||
| 27 | + const child = spawnSync(process.execPath, getArgs(port)); | ||
| 28 | + const stderr = child.stderr.toString().trim(); | ||
| 29 | + const stdout = child.stdout.toString().trim(); | ||
| 30 | + console.log('[STDERR]'); | ||
| 31 | + console.log(stderr); | ||
| 32 | + console.log('[STDOUT]'); | ||
| 33 | + console.log(stdout); | ||
| 34 | + const match = stderr.match( | ||
| 35 | + /Starting inspector on 127\.0\.0\.1:(\d+) failed: address already in use/ | ||
| 36 | + ); | ||
| 37 | + assert.notStrictEqual(match, null); | ||
| 38 | + assert.strictEqual(match[1], port + ''); | ||
| 39 | + assert.strictEqual(child.status, exitCode); | ||
| 40 | + }); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + testChildProcess( | ||
| 44 | + (port) => [`--inspect=${port}`, '--build-snapshot', entry], 0); | ||
| 45 | + testChildProcess( | ||
| 46 | + (port) => [`--inspect=${port}`, entry], 0); | ||
| 47 | + | ||
| 48 | + testOnServerListen((server) => { | ||
| 49 | + const { port } = server.address(); | ||
| 50 | + const worker = new Worker(entry, { | ||
| 51 | + execArgv: [`--inspect=${port}`] | ||
| 52 | + }); | ||
| 53 | + | ||
| 54 | + worker.on('error', common.mustNotCall()); | ||
| 55 | + | ||
| 56 | + worker.on('exit', common.mustCall((code) => { | ||
| 57 | + assert.strictEqual(code, 0); | ||
| 58 | + })); | ||
| 59 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments