Skip to content

Commit

Permalink
fix: Only use AbortController when needed
Browse files Browse the repository at this point in the history
Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
  • Loading branch information
GordonSmith committed Oct 3, 2021
1 parent 9d843cc commit 066e2ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ecl/eclWatchPanelView.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";
import { send } from "@hpcc-js/comms";
import { hashSum, join } from "@hpcc-js/util";
import { hashSum } from "@hpcc-js/util";
import { LaunchProtocol } from "../debugger/launchRequestArguments";
import { wuDetailsUrl, wuResultUrl } from "../hpccplatform/launchConfig";
import { sessionManager } from "../hpccplatform/session";
Expand Down Expand Up @@ -99,8 +99,10 @@ export class ECLWatchPanelView implements vscode.WebviewViewProvider {
}
break;
case "proxySend":
abortControllers[message.id] = new AbortController();
message.params.request.abortSignal_ = abortControllers[message.id].signal;
if (message.canAbort) {
abortControllers[message.id] = new AbortController();
message.params.request.abortSignal_ = abortControllers[message.id].signal;
}
send(message.params.opts, message.params.action, message.params.request, message.params.responseType, message.params.header).then(response => {
this._webviewView.webview.postMessage({
command: "proxyResponse",
Expand Down
3 changes: 3 additions & 0 deletions src/eclwatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ let proxyID = 0;

const origSend = hookSend((opts, action, request, responseType, header) => {
const id = ++proxyID;
let canAbort = false;
if (request.abortSignal_) {
canAbort = true;
request.abortSignal_.onabort = function () {
vscode.postMessage<ProxyCancelMessage>({
command: "proxyCancel",
Expand All @@ -40,6 +42,7 @@ const origSend = hookSend((opts, action, request, responseType, header) => {
vscode.postMessage<ProxySendMessage>({
command: "proxySend",
id,
canAbort,
params: {
opts,
action,
Expand Down
1 change: 1 addition & 0 deletions src/eclwatch/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface LoadedMessage extends Message {
export interface ProxySendMessage extends Message {
command: "proxySend";
id: number;
canAbort: boolean;
params: {
opts: any;
action: any;
Expand Down

0 comments on commit 066e2ae

Please sign in to comment.