From e5655033c15a01faac5da187440448ec4269d657 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 20 Sep 2021 12:52:49 +0500 Subject: [PATCH 1/2] fix(jobExecutor): appending resend requests before login call --- sasjs-tests/src/testSuites/Basic.ts | 4 ++-- src/job-execution/ComputeJobExecutor.ts | 3 ++- src/job-execution/JesJobExecutor.ts | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sasjs-tests/src/testSuites/Basic.ts b/sasjs-tests/src/testSuites/Basic.ts index 014a549..d3e9f21 100644 --- a/sasjs-tests/src/testSuites/Basic.ts +++ b/sasjs-tests/src/testSuites/Basic.ts @@ -78,8 +78,8 @@ export const basicTests = ( 'common/sendArr', stringData, undefined, - () => { - adapter.logIn(userName, password) + async () => { + await adapter.logIn(userName, password) } ) }, diff --git a/src/job-execution/ComputeJobExecutor.ts b/src/job-execution/ComputeJobExecutor.ts index d0a6ba6..b0f959f 100644 --- a/src/job-execution/ComputeJobExecutor.ts +++ b/src/job-execution/ComputeJobExecutor.ts @@ -45,7 +45,6 @@ export class ComputeJobExecutor extends BaseJobExecutor { } if (e instanceof LoginRequiredError) { - await loginCallback() this.appendWaitingRequest(() => { return this.execute( sasJob, @@ -61,6 +60,8 @@ export class ComputeJobExecutor extends BaseJobExecutor { } ) }) + + await loginCallback() } else { reject(new ErrorResponse(e?.message, e)) } diff --git a/src/job-execution/JesJobExecutor.ts b/src/job-execution/JesJobExecutor.ts index 464c4b0..72cc848 100644 --- a/src/job-execution/JesJobExecutor.ts +++ b/src/job-execution/JesJobExecutor.ts @@ -45,8 +45,6 @@ export class JesJobExecutor extends BaseJobExecutor { } if (e instanceof LoginRequiredError) { - await loginCallback() - this.appendWaitingRequest(() => { return this.execute( sasJob, @@ -64,6 +62,8 @@ export class JesJobExecutor extends BaseJobExecutor { } ) }) + + await loginCallback() } else { reject(new ErrorResponse(e?.message, e)) } From 369a035e8aee642c9af542511e21f6a0a5413f6e Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 20 Sep 2021 13:28:41 +0500 Subject: [PATCH 2/2] 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 : ''