Skip to content

Commit 4c7bd7d

Browse files
committed
Check for undefined/null client and add try/catch for retrieving shc info
1 parent 6adf16a commit 4c7bd7d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

out/notebooks/controller.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,21 @@ export class SplunkController {
7979
const restUrl = config.get<string>('splunk.commands.splunkRestUrl');
8080
const token = config.get<string>('splunk.commands.token');
8181
// Create a new SDK client if one hasn't been created or token / url settings have been changed
82-
if (!this._service || (this._service._originalURL !== restUrl) || (this._service.sessionKey !== token)) {
82+
if ((this._service === undefined)
83+
|| (this._service === null)
84+
|| (this._service._originalURL !== restUrl)
85+
|| (this._service.sessionKey !== token)
86+
) {
8387
this._service = getClient();
8488
// Check to see if the splunk deployment is part of a search head cluster, choose a single search head
8589
// to target if so to ensure that adhoc jobs are immediately available (without replication)
86-
const newService = await getSearchHeadClusterMemberClient(this._service);
87-
this._service = newService;
90+
try {
91+
const newService = await getSearchHeadClusterMemberClient(this._service);
92+
this._service = newService;
93+
} catch (err) {
94+
console.warn(`Error retrieving search head cluster information:`);
95+
console.warn(err);
96+
}
8897
}
8998
}
9099

0 commit comments

Comments
 (0)