Skip to content

Conversation

@RubaXa
Copy link
Contributor

@RubaXa RubaXa commented Feb 11, 2025

No description provided.


this.callbacks.beforeHandleMessage(this, data)
.then(() => {
this.nextProcessBeforeHandleMessage()
Copy link
Contributor

Choose a reason for hiding this comment

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

The ordering of things here seems a bit off to me: you trigger the processing of a next message before you've processed this one (below).

Copy link
Contributor

Choose a reason for hiding this comment

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

The invocation of this.nextProcessBeforeHandleMessage will initiate a new async sequence and to me it seems possible that things go out-of-order again.


logger: Debugger

private beforeHandleMessageQueue: Uint8Array[] = []
Copy link
Contributor

@raimohanska raimohanska Feb 16, 2025

Choose a reason for hiding this comment

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

You might be able to do with just 1 additional state variable if you shifted the message only after successfully processing it.

}

/** Process an incoming message */
private processBeforeHandleMessage(data: Uint8Array): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of the method is out of sync with the comment. I like the comment more, as what this methos does is process an incoming message after applying the beforeHandleMessage hooks.

}

/** Process an incoming message */
private processBeforeHandleMessage(data: Uint8Array): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer using async-await syntax for this method. This would allow you to use a while (this. beforeHandleMessageQueue.length > 0 loop.

@raimohanska
Copy link
Contributor

What's going on with this one?

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.

2 participants