tvkitchen / countertop

The entry point for developers who want to set up a TV Kitchen.
https://tv.kitchen
GNU Lesser General Public License v3.0
6 stars 2 forks source link

Error: write EPIPE in AbstractIngestionEngine / Promise { <pending> } #59

Closed chriszs closed 4 years ago

chriszs commented 4 years ago

Bug

Current Behavior

When I try to inherit from the AbstractIngestionEngine and use it to stream from a file (after fixing #57 and #58), I get:

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:92:16)
Emitted 'error' event on Socket instance at:
    at Socket.onerror (_stream_readable.js:753:14)
    at Socket.emit (events.js:315:20)
    at Socket.EventEmitter.emit (domain.js:485:12)
    at emitErrorNT (internal/streams/destroy.js:100:8)
    at emitErrorCloseNT (internal/streams/destroy.js:68:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

After adding a log statement for error events for each stream in the pipe, I get Promise { <pending> } as an error from the ingestPayload stream. This is the promise produced by this.producer.send and passed as the first argument to done, which is interpreted as an error because that's convention for callbacks.

Input

yarn babel-node src/components/ingestion/test.js
// src/components/ingestion/test.js
import 'module-alias/register'
import AbstractIngestionEngine from './AbstractIngestionEngine'

class FileIngestionEngine extends AbstractIngestionEngine {
    constructor(path) {
        super()

        this.path = path
    }

    path = null

    getInputStream = () => fs.createReadStream(this.path)
}

const engine = new FileIngestionEngine(__dirname + '/in.ts')

engine.start()

Expected Behavior

I expected it to not throw that error.

Possible Solutions

Wait for the promise from sending to the producer, call done() without a first argument on success.

.then(result => done(null,result)).catch(done)

Related Issues

57 and #58

slifty commented 4 years ago

Argh -- ty for flagging this.

Let the record show that I very much do not like that callback convention.

image

chriszs commented 4 years ago

Would you prefer a more async/await style? Is this my chance to sneak my promisification into this?

slifty commented 4 years ago

~Oh boy yes let's do it!~

I guess the responsible thing to do would be to fix the bug and treat promise refactoring as a separate issue ... bah.

slifty commented 4 years ago

Closed by #56