Skip to content

Commit

Permalink
Standalone browser timeout and catch
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Oct 14, 2023
1 parent 2c76b64 commit f97bfb9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
13 changes: 10 additions & 3 deletions Assets/Thirdweb/Core/Scripts/WalletsUI/EmbeddedWalletUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,16 @@ public void OpenURL(string url)
#else
public async void OpenURL(string url)
{
var standaloneBrowser = new StandaloneBrowser();
var res = await standaloneBrowser.StartAsync(url, "http://localhost:8789/");
_redirectUrl = res.redirectUrl;
try
{
var standaloneBrowser = new StandaloneBrowser();
var res = await standaloneBrowser.StartAsync(url, "http://localhost:8789/");
_redirectUrl = res.redirectUrl;
}
catch (System.Exception e)
{
_exception = e;
}
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ public async Task<BrowserResult> StartAsync(string loginUrl, string redirectUrl,

Application.OpenURL(loginUrl);

return await _taskCompletionSource.Task;
var completedTask = await Task.WhenAny(_taskCompletionSource.Task, Task.Delay(TimeSpan.FromSeconds(60)));
if (completedTask == _taskCompletionSource.Task)
{
return await _taskCompletionSource.Task;
}
else
{
throw new TimeoutException("The operation timed out.");
}
}
finally
{
Expand Down

0 comments on commit f97bfb9

Please sign in to comment.