| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a1ecdcf commit 1b54371
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -829,10 +829,11 @@ Node.js does not allow `stdout` or `stderr` Streams to be closed by user code. | |||
| 829 | 829 | Used when an attempt is made to close the `process.stdout` stream. By design, | |
| 830 | 830 | Node.js does not allow `stdout` or `stderr` Streams to be closed by user code. | |
| 831 | 831 | ||
| 832 | - <a id="ERR_STREAM_HAS_STRINGDECODER"></a> | ||
| 833 | - ### ERR_STREAM_HAS_STRINGDECODER | ||
| 832 | + <a id="ERR_STREAM_WRAP"></a> | ||
| 833 | + ### ERR_STREAM_WRAP | ||
| 834 | 834 | ||
| 835 | - Used to prevent an abort if a string decoder was set on the Socket. | ||
| 835 | + Used to prevent an abort if a string decoder was set on the Socket or if in | ||
| 836 | + `objectMode`. | ||
| 836 | 837 | ||
| 837 | 838 | Example | |
| 838 | 839 | ```js | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,7 +76,7 @@ function afterTransform(er, data) { | |||
| 76 | 76 | ||
| 77 | 77 | var cb = ts.writecb; | |
| 78 | 78 | ||
| 79 | - if (!cb) { | ||
| 79 | + if (cb === null) { | ||
| 80 | 80 | return this.emit('error', new errors.Error('ERR_MULTIPLE_CALLBACK')); | |
| 81 | 81 | } | |
| 82 | 82 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,9 +4,6 @@ const assert = require('assert'); | |||
| 4 | 4 | const util = require('util'); | |
| 5 | 5 | const Socket = require('net').Socket; | |
| 6 | 6 | const JSStream = process.binding('js_stream').JSStream; | |
| 7 | - // TODO(bmeurer): Change this back to const once hole checks are | ||
| 8 | - // properly optimized away early in Ignition+TurboFan. | ||
| 9 | - var Buffer = require('buffer').Buffer; | ||
| 10 | 7 | const uv = process.binding('uv'); | |
| 11 | 8 | const debug = util.debuglog('stream_wrap'); | |
| 12 | 9 | const errors = require('internal/errors'); | |
@@ -47,12 +44,12 @@ function StreamWrap(stream) { | |||
| 47 | 44 | self.emit('error', err); | |
| 48 | 45 | }); | |
| 49 | 46 | this.stream.on('data', function ondata(chunk) { | |
| 50 | - if (!(chunk instanceof Buffer)) { | ||
| 47 | + if (typeof chunk === 'string' || this._readableState.objectMode === true) { | ||
| 51 | 48 | // Make sure that no further `data` events will happen | |
| 52 | 49 | this.pause(); | |
| 53 | 50 | this.removeListener('data', ondata); | |
| 54 | 51 | ||
| 55 | - self.emit('error', new errors.Error('ERR_STREAM_HAS_STRINGDECODER')); | ||
| 52 | + self.emit('error', new errors.Error('ERR_STREAM_WRAP')); | ||
| 56 | 53 | return; | |
| 57 | 54 | } | |
| 58 | 55 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -171,7 +171,7 @@ E('ERR_SOCKET_BAD_PORT', 'Port should be > 0 and < 65536'); | |||
| 171 | 171 | E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running'); | |
| 172 | 172 | E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed'); | |
| 173 | 173 | E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed'); | |
| 174 | - E('ERR_STREAM_HAS_STRINGDECODER', 'Stream has StringDecoder'); | ||
| 174 | + E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode'); | ||
| 175 | 175 | E('ERR_TRANSFORM_ALREADY_TRANSFORMING', | |
| 176 | 176 | 'Calling transform done when still transforming'); | |
| 177 | 177 | E('ERR_TRANSFORM_WITH_LENGTH_0', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,42 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | - const assert = require('assert'); | ||
| 4 | 3 | ||
| 5 | 4 | const StreamWrap = require('_stream_wrap'); | |
| 6 | 5 | const Duplex = require('stream').Duplex; | |
| 7 | 6 | ||
| 8 | - const stream = new Duplex({ | ||
| 9 | - read: function() { | ||
| 10 | - }, | ||
| 11 | - write: function() { | ||
| 12 | - } | ||
| 13 | - }); | ||
| 7 | + { | ||
| 8 | + const stream = new Duplex({ | ||
| 9 | + read() {}, | ||
| 10 | + write() {} | ||
| 11 | + }); | ||
| 14 | 12 | ||
| 15 | - stream.setEncoding('ascii'); | ||
| 13 | + stream.setEncoding('ascii'); | ||
| 16 | 14 | ||
| 17 | - const wrap = new StreamWrap(stream); | ||
| 15 | + const wrap = new StreamWrap(stream); | ||
| 18 | 16 | ||
| 19 | - wrap.on('error', common.mustCall(function(err) { | ||
| 20 | - assert(/StringDecoder/.test(err.message)); | ||
| 21 | - })); | ||
| 17 | + wrap.on('error', common.expectsError({ | ||
| 18 | + type: Error, | ||
| 19 | + code: 'ERR_STREAM_WRAP', | ||
| 20 | + message: 'Stream has StringDecoder set or is in objectMode' | ||
| 21 | + })); | ||
| 22 | 22 | ||
| 23 | - stream.push('ohai'); | ||
| 23 | + stream.push('ohai'); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + { | ||
| 27 | + const stream = new Duplex({ | ||
| 28 | + read() {}, | ||
| 29 | + write() {}, | ||
| 30 | + objectMode: true | ||
| 31 | + }); | ||
| 32 | + | ||
| 33 | + const wrap = new StreamWrap(stream); | ||
| 34 | + | ||
| 35 | + wrap.on('error', common.expectsError({ | ||
| 36 | + type: Error, | ||
| 37 | + code: 'ERR_STREAM_WRAP', | ||
| 38 | + message: 'Stream has StringDecoder set or is in objectMode' | ||
| 39 | + })); | ||
| 40 | + | ||
| 41 | + stream.push(new Error('foo')); | ||
| 42 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments