From 369a035e8aee642c9af542511e21f6a0a5413f6e Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 20 Sep 2021 13:28:41 +0500 Subject: [PATCH] fix(webJobExecutor): append resend request for viya's getJobUri authentication --- src/job-execution/WebJobExecutor.ts | 31 ++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/job-execution/WebJobExecutor.ts b/src/job-execution/WebJobExecutor.ts index 1476a35..db054cc 100644 --- a/src/job-execution/WebJobExecutor.ts +++ b/src/job-execution/WebJobExecutor.ts @@ -53,7 +53,36 @@ export class WebJobExecutor extends BaseJobExecutor { let apiUrl = `${config.serverUrl}${this.jobsPath}/?${'_program=' + program}` if (config.serverType === ServerType.SasViya) { - const jobUri = await this.getJobUri(sasJob) + let jobUri + try { + jobUri = await this.getJobUri(sasJob) + } catch (e: any) { + return new Promise(async (resolve, reject) => { + if (e instanceof LoginRequiredError) { + this.appendWaitingRequest(() => { + return this.execute( + sasJob, + data, + config, + loginRequiredCallback, + authConfig, + extraResponseAttributes + ).then( + (res: any) => { + resolve(res) + }, + (err: any) => { + reject(err) + } + ) + }) + + await loginCallback() + } else { + reject(new ErrorResponse(e?.message, e)) + } + }) + } apiUrl += jobUri.length > 0 ? '&_job=' + jobUri : ''