| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4cdf000 commit 99c033e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -583,9 +583,10 @@ void CustomBufferJSListener::OnStreamRead(ssize_t nread, const uv_buf_t& buf) { | |||
| 583 | 583 | HandleScope handle_scope(env->isolate()); | |
| 584 | 584 | Context::Scope context_scope(env->context()); | |
| 585 | 585 | ||
| 586 | - // To deal with the case where POLLHUP is received and UV_EOF is returned, as | ||
| 587 | - // libuv returns an empty buffer (on unices only). | ||
| 588 | - if (nread == UV_EOF && buf.base == nullptr) { | ||
| 586 | + // In the case that there's an error and buf is null, return immediately. | ||
| 587 | + // This can happen on unices when POLLHUP is received and UV_EOF is returned | ||
| 588 | + // or when getting an error while performing a UV_HANDLE_ZERO_READ on Windows. | ||
| 589 | + if (buf.base == nullptr && nread < 0) { | ||
| 589 | 590 | stream->CallJSOnreadMethod(nread, Local<ArrayBuffer>()); | |
| 590 | 591 | return; | |
| 591 | 592 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,47 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { spawn } = require('child_process'); | ||
| 6 | + const net = require('net'); | ||
| 7 | + | ||
| 8 | + if (process.argv[2] === 'child') { | ||
| 9 | + const server = net.createServer(common.mustCall()); | ||
| 10 | + server.listen(0, common.mustCall(() => { | ||
| 11 | + process.send({ type: 'ready', data: { port: server.address().port } }); | ||
| 12 | + })); | ||
| 13 | + } else { | ||
| 14 | + const cp = spawn(process.execPath, | ||
| 15 | + [__filename, 'child'], | ||
| 16 | + { | ||
| 17 | + stdio: ['ipc', 'inherit', 'inherit'] | ||
| 18 | + }); | ||
| 19 | + | ||
| 20 | + cp.on('exit', common.mustCall((code, signal) => { | ||
| 21 | + assert.strictEqual(code, null); | ||
| 22 | + assert.strictEqual(signal, 'SIGKILL'); | ||
| 23 | + })); | ||
| 24 | + | ||
| 25 | + cp.on('message', common.mustCall((msg) => { | ||
| 26 | + const { type, data } = msg; | ||
| 27 | + assert.strictEqual(type, 'ready'); | ||
| 28 | + const port = data.port; | ||
| 29 | + | ||
| 30 | + const conn = net.createConnection({ | ||
| 31 | + port, | ||
| 32 | + onread: { | ||
| 33 | + buffer: Buffer.alloc(65536), | ||
| 34 | + callback: () => {}, | ||
| 35 | + } | ||
| 36 | + }); | ||
| 37 | + | ||
| 38 | + conn.on('error', (err) => { | ||
| 39 | + // Error emitted on Windows. | ||
| 40 | + assert.strictEqual(err.code, 'ECONNRESET'); | ||
| 41 | + }); | ||
| 42 | + | ||
| 43 | + conn.on('connect', common.mustCall(() => { | ||
| 44 | + cp.kill('SIGKILL'); | ||
| 45 | + })); | ||
| 46 | + })); | ||
| 47 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments