-
Notifications
You must be signed in to change notification settings - Fork 55
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
Make ICipher.decrypt
async
#1311
Merged
lawrence-forooghian
merged 13 commits into
integration/v2
from
1293-make-ICipher.decrypt-async
Jun 5, 2023
Merged
Make ICipher.decrypt
async
#1311
lawrence-forooghian
merged 13 commits into
integration/v2
from
1293-make-ICipher.decrypt-async
Jun 5, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
temporarily deployed
to
staging/pull/1311/bundle-report
May 30, 2023 12:06
Inactive
lawrence-forooghian
force-pushed
the
1293-make-ICipher.decrypt-async
branch
from
May 31, 2023 19:41
77a899a
to
b5d5a5d
Compare
github-actions
bot
temporarily deployed
to
staging/pull/1311/bundle-report
May 31, 2023 19:43
Inactive
lawrence-forooghian
force-pushed
the
1293-make-ICipher.decrypt-async
branch
from
May 31, 2023 20:01
b5d5a5d
to
1bf4b43
Compare
github-actions
bot
temporarily deployed
to
staging/pull/1311/bundle-report
May 31, 2023 20:03
Inactive
lawrence-forooghian
force-pushed
the
1293-make-ICipher.decrypt-async
branch
from
June 1, 2023 13:58
1bf4b43
to
bf81547
Compare
github-actions
bot
temporarily deployed
to
staging/pull/1311/bundle-report
June 1, 2023 13:59
Inactive
lawrence-forooghian
force-pushed
the
1293-make-ICipher.decrypt-async
branch
from
June 1, 2023 14:37
bf81547
to
5ccfe55
Compare
github-actions
bot
temporarily deployed
to
staging/pull/1311/bundle-report
June 1, 2023 14:38
Inactive
owenpearson
approved these changes
Jun 5, 2023
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, nicely done :)
lawrence-forooghian
force-pushed
the
convert-crypto-to-TypeScript
branch
from
June 5, 2023 16:39
a56148c
to
b7977e4
Compare
As part of #1293 (making ICipher.decrypt asynchronous), we will be making this method async, and another method will wish to wait on its completion. As such, this should no longer be named as if it were only an informative callback.
This is preparation for #1293 (making ICipher.decrypt asynchronous). This will require us to make RealtimeChannel#processMessage asynchronous. Since RealtimeChannel#processMessage reads from and writes to the _decodingContext.baseEncodedPreviousPayload property of the channel, we need to ensure that, once this method becomes asynchronous, we serialise access to this method — that is, we wait for one call to complete before performing the next. To do this, we need to introduce a queue. I decided to put this queue at the level of the ConnectionManager instead of RealtimeChannel. This is because ConnectionManager also has its own logic for deciding whether a message should be processed — specifically, whether it comes from the current transport — and I thought it made sense to evaluate these conditions at the moment we pass the message to the channel. I’m not 100% sure this is the right choice, though, since it means that the synchronisation is now the concern of three components (ConnectionManager, Channels, RealtimeChannel) when it instead could be the concern of just RealtimeChannel. But we can always revisit this. The handling of the case where ConnectionManager#processChannelMessage throws an error is copied from the places where this error was previously handled — namely, WebSocketTransport.onWsData and CometTransport.onData, both of which log an error message without affecting the processing of subsequent messages. (Note also that this marks the first use of `async` or promises internally in the library. We have avoided this until now because we were not guaranteed to be running in browsers with Promise support, but since the library will _only_ be exposing a Promise API as of #1199, which is also scheduled for version 2.0, we’re fine to start doing so now.)
Preparation for #1293 (making ICipher.decrypt asynchronous).
These are the tests that call RealtimeChannel#processMessage at their top level. This is preparation for making that method asynchronous as part of #1293 (making ICipher.decrypt asynchronous).
Preparation for #1293 (making ICipher.decrypt asynchronous).
Preparation for #1293 (making ICipher.decrypt asynchronous).
Preparation for #1293 (making ICipher.decrypt asynchronous).
Preparation for #1293 (making ICipher.decrypt asynchronous).
Preparation for #1293 (making ICipher.decrypt asynchronous).
lawrence-forooghian
force-pushed
the
1293-make-ICipher.decrypt-async
branch
from
June 5, 2023 20:11
5ccfe55
to
c955702
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: This is based on top of #1246; please review that one first.
This makes
ICipher.decrypt
async, in preparation for using the (async-only)SubtleCrypto.decrypt
method in #1292.The changes of note are:
RealtimeChannel#processMessage
async — involves adding a queue to synchronise access to this method{Message, PresenceMessage}#{fromEncoded, fromEncodedArray}
methods asyncSee commit messages for more details.
Resolves #1293.