From 4836f3b9b9355a52f139d4f626f26aa4f2475ef3 Mon Sep 17 00:00:00 2001 From: Eugene Ostroukhov Date: Mon, 24 Jul 2017 16:00:08 -0700 Subject: [PATCH] inspector: send messages after the Node is done Fixes: https://github.com/nodejs/node/issues/14432 PR-URL: https://github.com/nodejs/node/pull/14463 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/inspector_io.cc | 2 -- .../test-inspector-stop-profile-after-done.js | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/inspector/test-inspector-stop-profile-after-done.js diff --git a/src/inspector_io.cc b/src/inspector_io.cc index a7d69263edad6d..12a0d20720354a 100644 --- a/src/inspector_io.cc +++ b/src/inspector_io.cc @@ -429,8 +429,6 @@ void InspectorIo::MainThreadReqAsyncCb(uv_async_t* req) { void InspectorIo::Write(TransportAction action, int session_id, const StringView& inspector_message) { - if (state_ == State::kShutDown) - return; AppendMessage(&outgoing_message_queue_, action, session_id, StringBuffer::create(inspector_message)); int err = uv_async_send(&thread_req_); diff --git a/test/inspector/test-inspector-stop-profile-after-done.js b/test/inspector/test-inspector-stop-profile-after-done.js new file mode 100644 index 00000000000000..db43e4ae79c4bd --- /dev/null +++ b/test/inspector/test-inspector-stop-profile-after-done.js @@ -0,0 +1,21 @@ +'use strict'; +const common = require('../common'); +common.skipIfInspectorDisabled(); +const helper = require('./inspector-helper.js'); + +function test(session) { + session.sendInspectorCommands([ + { 'method': 'Runtime.runIfWaitingForDebugger' }, + { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, + { 'method': 'Profiler.enable' }, + { 'method': 'Profiler.start' }]); + session.expectStderrOutput('Waiting for the debugger to disconnect...'); + session.sendInspectorCommands({ 'method': 'Profiler.stop' }); + session.disconnect(true); +} + +function runTests(harness) { + harness.runFrontendSession([test]).expectShutDown(0); +} + +helper.startNodeForInspectorTest(runTests, ['--inspect-brk'], 'let a = 2;');