mux-demux tries to write to stream after it's closed #7

Closed
Raynos opened this Issue Aug 9, 2012 · 6 comments

Comments

Projects
None yet
2 participants
@Raynos
Contributor

Raynos commented Aug 9, 2012

After a stream is closed I get a write message incoming and this throws a stream is not writable Error.

This could be a race condition with buffering data whilst opening and closing connections or a bug in my code.

As always running seaport-proxy service demo and repeatedly opening and closing connections get's this error to bubble up.

mux-demux would be a lot more friendly if it just drops connections that are in a corrupted state rather then throwing an exception and killing my server. Calling stream.end() instead of throw new Error("fix your race conditions") would be nicer.

function createStream(id, meta, opts) {
    console.log("[CREATE] creatingStream", id)
    var s = es.through(function (data) {
      if(!this.writable) {
        console.log("[NOT WRITABLE]", id, meta, opts)
        throw new Error('stream is not writable')
      }
      md.emit('data', [s.id, 'data', data])
    }, function () {
      md.emit('data', [s.id, 'end'])
      if (this.readable && !opts.allowHalfOpen && !this.ended) {
        this.emit("end")
      }
    })
@dominictarr

This comment has been minimized.

Show comment
Hide comment
@dominictarr

dominictarr Aug 9, 2012

Owner

If it's not writable that means that it's already emitted end, close or error.
(yeah, there are too many ways a stream can end, but that will change in 0.9)

can you post a stacktrace?

if you are using pipe to write to the stream, it will check whether it is writable,
and drop the write if it isn't.

does this crash on the server or on the browser?

Owner

dominictarr commented Aug 9, 2012

If it's not writable that means that it's already emitted end, close or error.
(yeah, there are too many ways a stream can end, but that will change in 0.9)

can you post a stacktrace?

if you are using pipe to write to the stream, it will check whether it is writable,
and drop the write if it isn't.

does this crash on the server or on the browser?

@Raynos

This comment has been minimized.

Show comment
Hide comment
@Raynos

Raynos Aug 9, 2012

Contributor

@dominictarr it crashes on the server.

I think I need a flag to change all the thrown errors for logging and closing streams as it's just not worth crashing my server for

Contributor

Raynos commented Aug 9, 2012

@dominictarr it crashes on the server.

I think I need a flag to change all the thrown errors for logging and closing streams as it's just not worth crashing my server for

@Raynos

This comment has been minimized.

Show comment
Hide comment
@Raynos

Raynos Aug 9, 2012

Contributor
@dominictarr

This comment has been minimized.

Show comment
Hide comment
@dominictarr

dominictarr Oct 26, 2012

Owner

@Raynos hey we fixed this right? we probably just talked about it in IRC and forgot about closing the issue.

Owner

dominictarr commented Oct 26, 2012

@Raynos hey we fixed this right? we probably just talked about it in IRC and forgot about closing the issue.

@Raynos

This comment has been minimized.

Show comment
Hide comment
@Raynos

Raynos Oct 26, 2012

Contributor

im sure this is fixed too.

Contributor

Raynos commented Oct 26, 2012

im sure this is fixed too.

@dominictarr

This comment has been minimized.

Show comment
Hide comment
@dominictarr

dominictarr Oct 26, 2012

Owner

cool, closing.

Owner

dominictarr commented Oct 26, 2012

cool, closing.

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