Skip to content

socket closes too early on sync writes #13

@dignifiedquire

Description

@dignifiedquire

When running a server in node like this

const createServer = require('pull-ws/server')
const pull = require('pull-stream')

createServer((stream) => {
  pull(stream, stream)
}).listen(5555)

and a client like this

pull(
  pull.infinite(),
  pull.take(100),
  // delay(0),
  connect('ws://localhost:5555'),
  pull.collect((err, result) => {
    if (err) throw err
    assert(result.length === 100)
  })
)

function delay (n) {
  return (read) => (err, cb) => {
    if (err) return read(err)
    setTimeout(() => {
      read(null, cb)
    }, n)
  }
}

It fails, with the result being equal to only the first element in the series. If I uncomment the delay it works as expected.
I took the delay definition out of the tests in here, so it seems this is somewhat known, but it still is a problem for me.
I looked at the traffic in the browser and all things are sent and received, just the pull-stream itself is aborted without forwarding all the messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions