-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
PM-2559 Messaging Rework for Passkey Bug #6282
Merged
Jingo88
merged 7 commits into
EC-598-beeep-properly-store-passkeys-in-bitwarden
from
vault/pom-2559-messaging-rework
Sep 27, 2023
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6330ae7
[PM-2559] Messaging Rework
cagonzalezcs 512e51e
remove unused sendResponse
Jingo88 621a80e
merged latest from EC-598 fix conflicts
Jingo88 31cf690
updated browser-api with default type and comments
Jingo88 d4ec395
put async back to await for lock in app component
Jingo88 e622101
minor refactor app component in browser
Jingo88 a08e7cf
removed unused code in app component browser
Jingo88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
question(non-blocking): why are changing from async/await to promise-then syntax? I usually think that the former is easier to read and more consistent with the majority of the code-base
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.
@coroiu
I agree with your sentiment here. What would make sense is to pull this behavior out to a separate method so we could still consider the async/await approach.
That suggestion aside, I advised Jason on these changes and can give a reason for why, in this instance, we're avoiding using the
await
keyword.When using the
chrome.runtime.onMessage.addListener
API, any callback that is passed to the listener needs to be structured as a syncrhonous callback. This is due to how thesendMessage
parameter is structured to respond when a message fromchrome.runtime.sendMessage
is received.The issue that we were seeing in this ticket was occurring because we were setting up the callbacks for
onMessage.addListener
asasync
methods, which by default return aPromise<void>
. Because of that, we were experiencing race conditions where somechrome.runtime.sendMessage
calls that were expecting a response from theonMessage
listener were receivingundefined
values.This MDN article explains a bit more on the issue - https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage#parameters
I think if @Jingo88 were to pull this behavior out to a private method, they could then place the method in the
onMessage
callback function without having to use a.then
chain.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.
Something akin to this.
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.
Ohhhhhhhh of course! I never occured to me that making the functions
async
would cause them to return aPromise
behind the scenes, which would be a truthy value. Someone is 100% going to fall for this again and having no idea what the issue is, this is the third time we're having to address this issue (first me, then Robyn, now Jason)!Could we maybe force the callbacks to return
boolean | void
and add a comment explaining whyPromises
are forbidden?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 that would be a solid idea.
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.
Leaving open to make it easier to find in the future