Skip to content

Commit

Permalink
Bind reject method to promise, improve typing
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Aug 12, 2024
1 parent 4351ad9 commit 6995078
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/jupyter-ai/src/completions/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class CompletionWebsocketHandler implements IDisposable {
(value: AiService.InlineCompletionReply) => void
> = {};

private _onClose(e: CloseEvent, reject: any) {
private _onClose(e: CloseEvent, reject: (reason: unknown) => void) {
reject(new Error('Inline completion websocket disconnected'));
console.error('Inline completion websocket disconnected');
// only attempt re-connect if there was an abnormal closure
Expand All @@ -137,7 +137,7 @@ export class CompletionWebsocketHandler implements IDisposable {
(token ? `?token=${encodeURIComponent(token)}` : '');

const socket = (this._socket = new WebSocket(url));
socket.onclose = e => this._onClose(e, promise.reject);
socket.onclose = e => this._onClose(e, promise.reject.bind(promise));
socket.onerror = e => promise.reject(e);
socket.onmessage = msg => msg.data && this._onMessage(JSON.parse(msg.data));
}
Expand Down

0 comments on commit 6995078

Please sign in to comment.