Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind reject method to promise, improve typing #949

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading