-
Notifications
You must be signed in to change notification settings - Fork 724
Open
Labels
Description
Opus wrote code that explicitly issued the StopAsync, which is how I noticed. Presumably the StopAsync isn't actually necessary, and that the client ideally shouldn't be stopped while there are active sessions, but disposal also should ideally be tolerant to such things.
Repro:
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await using var session = await client.CreateSessionAsync();
await client.StopAsync();results in this exception from the DisposeAsync from the await using cleanup:
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'StreamJsonRpc.JsonRpc'.
at Microsoft.Verify.NotDisposed(IDisposableObservable disposedValue, String message)
at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
at GitHub.Copilot.SDK.CopilotClient.InvokeRpcAsync[T](JsonRpc rpc, String method, Object[] args, CancellationToken cancellationToken)
at GitHub.Copilot.SDK.CopilotSession.DisposeAsync()
at Program.<Main>$(String[] args)