-
Notifications
You must be signed in to change notification settings - Fork 72
refactor(frontend): wait for signing keys instead of throwing #1923
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
base: main
Are you sure you want to change the base?
Conversation
Instead of throwing an error when we try to make requests before signing keys are ready, we enter a loop to wait for keys to exist. This prevents errors and the need to handle them, as well as making requests fire immediately when keys are eventually ready. Signed-off-by: Edward Sammut Alessi <[email protected]>
| </a> | ||
|
|
||
| <OngoingTasks v-if="authorized" /> | ||
| <OngoingTasks /> |
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.
| // Enter a loop to wait for keys to be ready. | ||
| // Request will fire when we have keys. | ||
| return await new Promise<string>((resolve) => { | ||
| setTimeout(() => { |
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.
this might be a dumb question, but why can't we make a function not fire an exception on no keys, and just wait on its own?
or have two versions, one which waits and another one which throws an error?
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'm trying to avoid the setTimeout loop here :)
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 setTimeout here is my version of waiting, it will essentially poll for keys every 100ms.
There are other ways to do it, could be with events & listeners for example, but I just went with the most straight forward option in front of me.
WDYT?
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 don't want to block the PR, I was just more curious if the Promise should not fail with "no keys" but itself wait for the keys to be establishes, avoiding the need to for polling.
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.
yeah, I'd also prefer some event handler instead

Instead of throwing an error when we try to make requests before signing keys are ready, we enter a loop to wait for keys to exist. This prevents errors and the need to handle them, as well as making requests fire immediately when keys are eventually ready.