Skip to content

Commit 52b6f06

Browse files
authored
Don't await browse.close task (#178)
1 parent 1d1820c commit 52b6f06

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/PuppeteerSharp/Browser.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ public async Task CloseAsync()
108108

109109
IsClosed = true;
110110

111-
await _closeCallBack();
111+
var closeTask = _closeCallBack();
112+
113+
if (closeTask != null)
114+
{
115+
await closeTask;
116+
}
117+
112118
Disconnect();
113119
Closed?.Invoke(this, new EventArgs());
114120
}

lib/PuppeteerSharp/Launcher.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ public async Task<Browser> ConnectAsync(ConnectOptions options)
195195

196196
_connection = await Connection.Create(options.BrowserWSEndpoint, connectionDelay, keepAliveInterval);
197197

198-
return await Browser.CreateAsync(_connection, options, () => _connection.SendAsync("Browser.close", null));
198+
return await Browser.CreateAsync(_connection, options, () =>
199+
{
200+
var closeTask = _connection.SendAsync("Browser.close", null);
201+
return null;
202+
});
199203
}
200204
catch (Exception ex)
201205
{

0 commit comments

Comments
 (0)