Skip to content

Commit 19bdfb0

Browse files
Fix language-service createClient
If no service is available for a partical file type (e.g. for "Dir" file type), the createClient function should return early instead if attempting to connect to an undefined Thrift endpoint.
1 parent 8e47609 commit 19bdfb0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

webgui-new/src/service/language-service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let client: LanguageService.Client | undefined;
77
export const createClient = (workspace: string, fileType: string | undefined) => {
88
if (!config || !fileType) return;
99

10-
const service = () =>
10+
const service = (() =>
1111
{
1212
switch(fileType)
1313
{
@@ -16,13 +16,15 @@ export const createClient = (workspace: string, fileType: string | undefined) =>
1616
case "PY":
1717
return "PythonService";
1818
}
19-
};
19+
})();
20+
21+
if (!service) return;
2022

2123
const connection = thrift.createXHRConnection(config.webserver_host, config.webserver_port, {
2224
transport: thrift.TBufferedTransport,
2325
protocol: thrift.TJSONProtocol,
2426
https: config.webserver_https,
25-
path: `${config.webserver_path}/${workspace}/${service()}`,
27+
path: `${config.webserver_path}/${workspace}/${service}`,
2628
});
2729
client = thrift.createXHRClient(LanguageService, connection);
2830
return client;

0 commit comments

Comments
 (0)