GeezerVison is showing github.com — test: wait for inspector restart before exit · nodejs/node@c01f8df
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-inspector-debug-end.js +10-5Lines changed: 10 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,18 +22,23 @@ async function testNoSessionNoCrash() { |
22 | 22 | async function testSessionNoCrash() { |
23 | 23 | console.log('Test there\'s no crash stopping server after connecting'); |
24 | 24 | const script = `process._debugEnd(); |
25 | | - process._debugProcess(process.pid); |
26 | | - setTimeout(() => { |
27 | | - console.log("Done"); |
28 | | - process.exit(42); |
29 | | - });`; |
| 25 | + process.stdin.once('data', () => { |
| 26 | + console.log("Done"); |
| 27 | + process.exit(42); |
| 28 | + }); |
| 29 | + process._debugProcess(process.pid);`; |
30 | 30 |
|
31 | 31 | const instance = new NodeInstance('--inspect-brk=0', script); |
32 | 32 | const session = await instance.connectInspectorSession(); |
33 | 33 | await session.send({ method: 'NodeRuntime.enable' }); |
34 | 34 | await session.waitForNotification('NodeRuntime.waitingForDebugger'); |
| 35 | + instance.resetPort(); |
35 | 36 | await session.send({ 'method': 'Runtime.runIfWaitingForDebugger' }); |
36 | 37 | await session.waitForServerDisconnect(); |
| 38 | + // _debugProcess() starts the inspector asynchronously. Wait for the new |
| 39 | + // server to listen before asking the child to exit. |
| 40 | + await instance.portPromise; |
| 41 | + instance.write('exit'); |
37 | 42 | assert.strictEqual((await instance.expectShutdown()).exitCode, 42); |
38 | 43 | } |
39 | 44 |
|
|