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

nowritecb error thrown #1

Closed
scottcorgan opened this issue Aug 2, 2013 · 12 comments
Closed

nowritecb error thrown #1

scottcorgan opened this issue Aug 2, 2013 · 12 comments

Comments

@scottcorgan
Copy link

Any reason why I would be getting the following error:

uncaughtException no writecb in Transform class
Error: no writecb in Transform class
    at afterTransform (/Users/scott/www/particle/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:92:33)
    at TransformState.afterTransform (/Users/scott/www/particle/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:76:1

Code worked using map-stream module. Converterted to try this module and getting this error now.

Thanks.

@rvagg
Copy link
Owner

rvagg commented Aug 2, 2013

it's possible this is due to not having a more consistent streams2 stack; one of the reasons I wrote this and also csv2 is because mixing and matching streams2 with other style streams can be a bit hit-and-miss.

Can you show me more of your code? What's piping in to your through2 stream? Also, your transformFrunction can't be bound to anything else, it must be passed in as a plain function that can participate as a member of the stream.Transform class.

@scottcorgan
Copy link
Author

Ya, I made sure the functions weren't bound to anything. It might by a mixture somewhere of the streams2 and streams somewhere in the pipe.

Would that cause it?

JSONStream does start it all off at the beginning of the pipes.

@rvagg
Copy link
Owner

rvagg commented Aug 2, 2013

JSONStream is based on through which I've had some streams2 compat issues with, but it seems to work ok with through2 with basic use:

var hyperquest = require('hyperquest')
  , JSONStream = require('JSONStream')
  , through2 = require('through2')

  hyperquest('http://isaacs.couchone.com/registry/_all_docs')
    .pipe(JSONStream.parse('rows.*'))
    .pipe(through2({ objectMode: true }, function (chunk, enc, callback) {
       this.push({ name: chunk.key })
       callback()
    }))
    .on('data', console.log)

->

{ name: '' }
{ name: '0' }
{ name: '007' }
{ name: '06_byvoidmodule' }
{ name: '0815' }
{ name: '0x21' }
{ name: '0x23' }
{ name: '1' }
{ name: '10tcl' }
{ name: '11zgit-fs' }
...

What else do you have in your stream stack? And is this error happening before you get any output, in the middle somewhere or at the end of a stream?

@scottcorgan
Copy link
Author

would an error be called if using the callback with

callback(null, cunk);

@rvagg
Copy link
Owner

rvagg commented Aug 2, 2013

I don't think it would cause an error. You can see the implementation of that callback here: https://github.com/joyent/node/blob/9e1eb361e8deb3f296a3c9d01de8fcc10361443f/lib/_stream_transform.js#L73-L106 - note there's a this.push(chunk) if you've passed a chunk. But that function is also where your original error is coming from, I'm not sure that's related thouh.

@rvagg
Copy link
Owner

rvagg commented Aug 2, 2013

    .pipe(through2({ objectMode: true }, function (chunk, enc, callback) {
       callback(null, { name: chunk.key })
    }))

does the same thing as the example above. There's no chance your callback is being re-bound to something else? it's just a plain callback(null, chunk)?

@brycebaril
Copy link
Collaborator

It looks like the way you get that error is by calling the callback twice, e.g.:

var spigot = require("stream-spigot")
var through = require("through2")

var tx = through(function (chunk, encoding, callback) {
  callback(null)
  callback(null, chunk)
})

spigot(["a", "b", "c", "d"])
  .pipe(tx)
  .pipe(process.stdout)
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: no writecb in Transform class
    at afterTransform (_stream_transform.js:90:33)
    at TransformState.afterTransform (_stream_transform.js:74:12)
    at Through2._transform (/tmp/t.js:6:9)
    at Through2.Transform._read (_stream_transform.js:179:10)
    at Through2.Transform._write (_stream_transform.js:167:12)
    at doWrite (_stream_writable.js:219:10)
    at writeOrBuffer (_stream_writable.js:209:5)
    at Through2.Writable.write (_stream_writable.js:180:11)
    at write (_stream_readable.js:573:24)
    at flow (_stream_readable.js:582:7)

@scottcorgan
Copy link
Author

@brycebaril I think it might not be about calling the callback twice as much as it is about calling the callback with a null value. But yo calling it twice produces the error as well.

Thanks for the heads up. Sent me in the right direction.

@scottcorgan
Copy link
Author

After updating to 0.0.5 and using the default streams class, I'm still getting the error. I'm going to assume it's my code and close the issue. I'll re open if I find otherwise.

Thanks for all the insight.

@rvagg
Copy link
Owner

rvagg commented Aug 2, 2013

Very interesting, but also very weird! Glad you fixed it though.

@towry
Copy link

towry commented Apr 8, 2015

I had this error today and the reason is I called the callback more than once.

@dcousens
Copy link

Thanks @towry 👍

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

No branches or pull requests

5 participants