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

fix: making endings clear and final. #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martinheidegger
Copy link
Contributor

This is an attempt to add clear end operations to streamx.

If .push(null) or .end() are called for a second time, streamx will now throw an Error alerting the user to that misuse of the API.
This PR fixes some incompatibility with Node.js (.writable becomes false after end).

Closes #44, #45

@martinheidegger martinheidegger force-pushed the clear-end branch 3 times, most recently from 902bc2d to 7ea4b4f Compare May 20, 2021 09:08
@pfrazee
Copy link

pfrazee commented Oct 19, 2021

This PR fixes some incompatibility with Node.js (.writable becomes false after end).

I just ran into this issue myself. I monkey patched around it with this:

// HACK
// this is a specific issue that's waiting on https://github.com/streamxorg/streamx/pull/46
// -prf
hyperswarmSocket._ended = false
const _end = hyperswarmSocket.end
hyperswarmSocket.end = function (data: any) {
  _end.call(this, data)
  this._ended = true
}
Object.defineProperty(hyperswarmSocket, 'writable', {
  get() {
    return !this._ended && this._writableState !== null ? true : undefined
  }
})

@martinheidegger

This comment has been minimized.

@martinheidegger
Copy link
Contributor Author

Rebase to the latest changes, though it looks like 9d3eed0 defines the current behavior as desired.

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

Successfully merging this pull request may close these issues.

Multiple end() calls should throw an error
2 participants