File tree 3 files changed +7
-15
lines changed
3 files changed +7
-15
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,6 @@ public class DevToolsSession : IDevToolsSession
55
55
56
56
private DevToolsDomains domains ;
57
57
58
- private readonly SemaphoreSlim semaphoreSlimForSocketSend = new SemaphoreSlim ( 1 , 1 ) ;
59
-
60
58
/// <summary>
61
59
/// Initializes a new instance of the DevToolsSession class, using the specified WebSocket endpoint.
62
60
/// </summary>
@@ -219,18 +217,7 @@ public T GetVersionSpecificDomains<T>() where T : DevToolsSessionDomains
219
217
220
218
string contents = JsonConvert . SerializeObject ( message ) ;
221
219
this . pendingCommands . TryAdd ( message . CommandId , message ) ;
222
-
223
- // socket SendAsync cannot be ran simultaneously, waiting available single worker
224
- await semaphoreSlimForSocketSend . WaitAsync ( cancellationToken ) ;
225
-
226
- try
227
- {
228
- await this . connection . SendData ( contents ) ;
229
- }
230
- finally
231
- {
232
- semaphoreSlimForSocketSend . Release ( ) ;
233
- }
220
+ await this . connection . SendData ( contents ) ;
234
221
235
222
var responseWasReceived = await Task . Run ( ( ) => message . SyncEvent . Wait ( millisecondsTimeout . Value , cancellationToken ) ) ;
236
223
@@ -335,7 +322,7 @@ protected void Dispose(bool disposing)
335
322
{
336
323
this . Domains . Target . TargetDetached -= this . OnTargetDetached ;
337
324
this . pendingCommands . Clear ( ) ;
338
- this . TerminateSocketConnection ( ) . GetAwaiter ( ) . GetResult ( ) ;
325
+ Task . Run ( async ( ) => await this . TerminateSocketConnection ( ) ) . GetAwaiter ( ) . GetResult ( ) ;
339
326
}
340
327
341
328
this . isDisposed = true ;
Original file line number Diff line number Diff line change @@ -186,6 +186,10 @@ protected virtual async Task CloseClientWebSocket()
186
186
{
187
187
// An OperationCanceledException is normal upon task/token cancellation, so disregard it
188
188
}
189
+ catch ( WebSocketException e )
190
+ {
191
+ this . Log ( $ "Unexpected error during attempt at close: { e . Message } ", DevToolsSessionLogLevel . Error ) ;
192
+ }
189
193
}
190
194
191
195
/// <summary>
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ public void Teardown()
39
39
{
40
40
session . Dispose ( ) ;
41
41
EnvironmentManager . Instance . CloseCurrentDriver ( ) ;
42
+ session = null ;
42
43
driver = null ;
43
44
}
44
45
}
You can’t perform that action at this time.
0 commit comments