Skip to content

Commit

Permalink
Add a timeout to solve promise resolving problem (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaMemmir5 authored Jan 18, 2024
1 parent cfa1f18 commit c52fff6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/oAuthClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,16 @@ export default class OAuthClient {
...params
})
if(auth.useWebMessage) {
return this.getWebMessage(
`${this.passwordlessVerifyUrl}?${queryString}`,
this.config.baseUrl,
auth.redirectUri
const timeout = (delay: number): Promise<void> => new Promise((resolve) => setTimeout(() => resolve(), delay))
const promiseGetWebMessage: Promise<void> = this.getWebMessage(
`${this.passwordlessVerifyUrl}?${queryString}`,
this.config.baseUrl,
auth.redirectUri
).then()
return Promise.race([
promiseGetWebMessage,
timeout(1000)
])
} else {
window.location.assign(`${this.passwordlessVerifyUrl}?${queryString}`)
return Promise.resolve()
Expand Down

0 comments on commit c52fff6

Please sign in to comment.