Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node 11.1.0 onStreamRead params have changed #6

Closed
daviddias opened this issue Nov 8, 2018 · 3 comments · Fixed by #13
Closed

node 11.1.0 onStreamRead params have changed #6

daviddias opened this issue Nov 8, 2018 · 3 comments · Fixed by #13
Labels

Comments

@daviddias
Copy link
Member

Keeping track of #5 (comment)

@jakubzitny
Copy link

Any update on this? It's still happening in Node 12.8.

vishai12345 added a commit to encoresky/handle-thing that referenced this issue Oct 18, 2019
@AliasPedroKarim
Copy link

AliasPedroKarim commented Oct 30, 2019

I had this problem (see issue #363) using node-spdy, I just reversed the parameter order of the function .onread for onStreamRead in internal / stream_base_commons.js but I had to change the handle-thing package to test. Now it works as before. (excuse me, my english is bad 😅)

handle-thing_file_handle-new

Error encountered :

internal/buffer.js:788
class FastBuffer extends Uint8Array {}
^

RangeError: Invalid typed array length: -4095
    at new Uint8Array (<anonymous>)
    at new FastBuffer (internal/buffer.js:788:1)
    at Handle.onStreamRead [as onread] (internal/stream_base_commons.js:153:17)
    at Stream.<anonymous> (C:\Users\xxx\Desktop\xxx\node_modules\handle-thing\lib\handle.js:88:10)
    at Stream.emit (events.js:198:15)
    at endReadableNT (C:\Users\xxx\Desktop\xxx\node_modules\spdy-transport\node_modules\readable-stream\lib\_stream_readable.js:1077:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:17)

newlukai pushed a commit to e2ebridge/handle-thing that referenced this issue Jan 15, 2020
- changed: wip version
@pecet86
Copy link

pecet86 commented Feb 18, 2020

Possible solution

add:

const NODE_MAJOR_VERSION = +process.versions.node.split('.')[0];
Handle.prototype._flow = function flow () {
  var self = this
  this._stream.on('data', function (chunk) {
		if (NODE_MAJOR_VERSION < 11) {
			self.onread(chunk.length, chunk)
		} else {
			self.onread(chunk)
		}
  })

  this._stream.on('end', function () {
		if (NODE_MAJOR_VERSION < 11) {
			self.onread(uv.UV_EOF, Buffer.alloc(0))
		} else {
			self.onread(Buffer.alloc(0))
		}
  })

  this._stream.on('close', function () {
    setImmediate(function () {
      if (self._reading) {
				if (NODE_MAJOR_VERSION < 11) {
					self.onread(uv.UV_ECONNRESET, Buffer.alloc(0))
				} else {
					self.onread(Buffer.alloc(0))
				}
      }
    })
  })
}

also works with versions <11 and> = 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

4 participants