| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0e18e68 commit 2b5b127
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,7 @@ if (cluster.isMaster) { | |||
| 33 | 33 | worker.on('message', common.mustCall(message => { | |
| 34 | 34 | assert.strictEqual(Array.isArray(message), true); | |
| 35 | 35 | assert.strictEqual(message[0], 'listening'); | |
| 36 | + let continueRecv = false; | ||
| 36 | 37 | const address = message[1]; | |
| 37 | 38 | const host = address.address; | |
| 38 | 39 | const debugClient = net.connect({ host, port: common.PORT }); | |
@@ -41,13 +42,25 @@ if (cluster.isMaster) { | |||
| 41 | 42 | debugClient.on('data', data => protocol.execute(data)); | |
| 42 | 43 | debugClient.once('connect', common.mustCall(() => { | |
| 43 | 44 | protocol.onResponse = common.mustCall(res => { | |
| 44 | - protocol.onResponse = () => {}; | ||
| 45 | + protocol.onResponse = (res) => { | ||
| 46 | + // It can happen that the first continue was sent before the break | ||
| 47 | + // event was received. If that's the case, send also a continue from | ||
| 48 | + // here so the worker exits | ||
| 49 | + if (res.body.command === 'continue') { | ||
| 50 | + continueRecv = true; | ||
| 51 | + } else if (res.body.event === 'break' && continueRecv) { | ||
| 52 | + const req = protocol.serialize({ command: 'continue' }); | ||
| 53 | + debugClient.write(req); | ||
| 54 | + } | ||
| 55 | + }; | ||
| 45 | 56 | const conn = net.connect({ host, port: address.port }); | |
| 46 | 57 | conn.once('connect', common.mustCall(() => { | |
| 47 | 58 | conn.destroy(); | |
| 48 | 59 | assert.notDeepStrictEqual(handles, {}); | |
| 49 | 60 | worker.disconnect(); | |
| 50 | 61 | assert.deepStrictEqual(handles, {}); | |
| 62 | + // Always send the continue, as the break event might have already | ||
| 63 | + // been received. | ||
| 51 | 64 | const req = protocol.serialize({ command: 'continue' }); | |
| 52 | 65 | debugClient.write(req); | |
| 53 | 66 | })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments