0

I can't find what is stopping the client from receiving my response. All of the code works and the command line shows response being sent but the client never gets it. I can force it with req.destroy or a Connection close header. Is there any way to see what is blocking it?

I'm piping req into busboy and then piping the file from busboy into a stream to validate the file. The problem is that when this is done I need to send the stream to a function. This is essentially how I am doing it now but it hangs when there is an error. I also have to raise the highWaterMark because I'm not consuming it.

    validateCSV
      .on('finish', () => {
        datasetService.import(validateCSV, dataset, (er) => {
           ....
        })
      }
      .on('error', (err) => {
        //The res never sends
        res.status(500).json(err).end();
      }

This works fine unless I emit an error from the Transform stream. Do I need to consume it in the data event? Should I be buffering the stream before using it the function?

This is what the stream looks like after the error:

ValidateCSV {
  _readableState: 
   ReadableState {
     objectMode: true,
     highWaterMark: 1000000,
     buffer: [],
     length: 0,
     pipes: null,
     pipesCount: 0,
     flowing: null,
     ended: false,
     endEmitted: false,
     reading: false,
     sync: false,
     needReadable: true,
     emittedReadable: false,
     readableListening: false,
     defaultEncoding: 'utf8',
     ranOut: false,
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: true,
  domain: null,
  _events: 
   { end: { [Function: g] listener: [Function: onend] },
     prefinish: { [Function: g] listener: [Function] },
     finish: [ [Function] ],
     error: [ [Function] ] },
  _eventsCount: 4,
  _maxListeners: undefined,
  _writableState: 
   WritableState {
     objectMode: true,
     highWaterMark: 1000000,
     needDrain: false,
     ending: false,
     ended: false,
     finished: false,
     decodeStrings: true,
     defaultEncoding: 'utf8',
     length: 1,
     writing: true,
     corked: 0,
     sync: true,
     bufferProcessing: false,
     onwrite: [Function],
     writecb: [Function: nop],
     writelen: 1,
     bufferedRequest: null,
     lastBufferedRequest: null,
     pendingcb: 1,
     prefinished: false,
     errorEmitted: false },
  writable: true,
  allowHalfOpen: true,
  _transformState: 
   TransformState {
     afterTransform: [Function],
     needTransfor`enter code here`m: false,
     transforming: true,
     writecb: [Function],
     writechunk: <Buffer 50 6f 6c 69 63 79 54 79 70 65 2c 4e 61 6d 65 2c 50 72 6f 70 41 64 64 72 65 73 73 32 2c 50 72 6f 70 43 69 74 79 2c 50 72 6f 70 5a 69 70 2c 50 6f 6c 69 ... >,
     writeencoding: 'buffer' } }
jabbermonkey
  • 1,680
  • 4
  • 19
  • 37

0 Answers0