-
Notifications
You must be signed in to change notification settings - Fork 6
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: various connection bugs #25
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! good tests :)
transport.send(m); | ||
} | ||
})(); | ||
|
||
// transport -> output | ||
const listener = (msg: OpaqueTransportMessage) => { | ||
if (belongsToSameStream(msg)) { | ||
if (isStreamClose(msg.controlFlags)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "stream close" msg wouldn't also contain normal message contents, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, stream close on the client means that message is the control message (it's kind of weird because its not the case for the server, can probably add an extra check here to make it consistent)
await stream.promises.inputHandler; | ||
stream.outgoing.end(); | ||
await stream.promises.outputHandler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we await these together?
Promises.all()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think it can actually, the input handler requires input
to be ended but output
to be open whereas output
requires output
to be ended
// we ended, send a close bit back to the client | ||
// only subscriptions and streams have streams the | ||
// handler can close |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client stream can't be closed by server? what if it's like "ah you're sending me too much data!" I guess then it would instead be "just use a stream"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client stream hasn't been implemented yet haha
} catch (err) { | ||
errorHandler(err); | ||
} | ||
})(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should throw here on unhandled procedure types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would probably allow us to not have to set inputHandler
to a resolved promise initially, which feels a bit weird.
this.ws.onmessage = (msg) => this.onMessage(msg.data as Uint8Array); | ||
|
||
// take over the onmessage for this websocket | ||
this.ws.onmessage = (msg) => transport.onMessage(msg.data as Uint8Array); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to remove these as
eventually
ws.onmessage
needed more documentation on what it was doingTransport
andConnection
(with a diagram!)WebSocketServerTransport
shouldn't close the underlyingwss
on.close()
(but it should terminate all connected clients)