Skip to content

Conversation

@sumimakito
Copy link
Member

This pull request makes the Promise returned by the invoke function reject when no invoke handlers were defined for the invoke event. This helps avoid producing Promises that never resolve or reject, which may be hard to troubleshoot.

function emit<P>(event: Eventa<P>, payload: P, options?: EmitOptions) {
function emit<P>(event: Eventa<P>, payload: P, options?: EmitOptions): boolean {
const emittingPayload = { ...event, body: payload }
let isConsumed = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid of this may not work as expected since if we are running electron & worker in different threads, the reference to how listener was called are different to how the emit in defineInvoke could get.

I think we might need to add one more event to InvokeEventa and call it as connected or consuming, then at least the peer that emit(s) the event would be able to be aware about whether there is a remote peer consuming the request. Along with the connected or consuming, we can add one more option called comsumingTimout works like how TCP timeout was. (maybe we could think about how we would work with UDP too.)

PS: oh and we could have a UDP adapter!

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants