From 5a2ee88cbc6e072d85a8940894022e1266600cd1 Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Mon, 11 Jan 2021 13:52:38 +0300 Subject: [PATCH 1/3] fix(job-status): print job status only if it changes --- src/SASViyaApiClient.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/SASViyaApiClient.ts b/src/SASViyaApiClient.ts index edbf002..2ae0b6e 100644 --- a/src/SASViyaApiClient.ts +++ b/src/SASViyaApiClient.ts @@ -1107,6 +1107,8 @@ export class SASViyaApiClient { } return new Promise(async (resolve, _) => { + let printedState = '' + const interval = setInterval(async () => { if ( postedJobState === 'running' || @@ -1114,9 +1116,6 @@ export class SASViyaApiClient { postedJobState === 'pending' ) { if (stateLink) { - if (this.debug) { - console.log('Polling job status... \n') - } const { result: jobState } = await this.request( `${this.serverUrl}${stateLink.href}?_action=wait&wait=30`, { @@ -1126,10 +1125,16 @@ export class SASViyaApiClient { ) postedJobState = jobState.trim() - if (this.debug) { + + if (this.debug && postedJobState !== printedState) { + console.log('Polling job status... \n') console.log(`Current state: ${postedJobState}\n`) + + printedState = postedJobState } + pollCount++ + if (pollCount >= MAX_POLL_COUNT) { resolve(postedJobState) } From 8f4d1c7aea5fc94e09f22df491326bba0960fbdc Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Tue, 12 Jan 2021 17:26:57 +0300 Subject: [PATCH 2/3] chore(*): improved session and job state logging --- src/SASViyaApiClient.ts | 6 +++--- src/SessionManager.ts | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/SASViyaApiClient.ts b/src/SASViyaApiClient.ts index 2ae0b6e..bac2d8e 100644 --- a/src/SASViyaApiClient.ts +++ b/src/SASViyaApiClient.ts @@ -1126,9 +1126,9 @@ export class SASViyaApiClient { postedJobState = jobState.trim() - if (this.debug && postedJobState !== printedState) { - console.log('Polling job status... \n') - console.log(`Current state: ${postedJobState}\n`) + if (this.debug && printedState !== postedJobState) { + console.log('Polling job status...') + console.log(`Current job state: ${postedJobState}`) printedState = postedJobState } diff --git a/src/SessionManager.ts b/src/SessionManager.ts index 1ff7cc2..1b63f17 100644 --- a/src/SessionManager.ts +++ b/src/SessionManager.ts @@ -23,6 +23,10 @@ export class SessionManager { private currentContext: Context | null = null private csrfToken: CsrfToken | null = null private _debug: boolean = false + private printedSessionState = { + printed: false, + state: '' + } public get debug() { return this._debug @@ -175,8 +179,10 @@ export class SessionManager { sessionState === '' ) { if (stateLink) { - if (this.debug) { - console.log('Polling session status... \n') + if (this.debug && !this.printedSessionState.printed) { + console.log('Polling session status...') + + this.printedSessionState.printed = true } const { result: state } = await this.requestSessionStatus( @@ -191,8 +197,11 @@ export class SessionManager { sessionState = state.trim() - if (this.debug) { - console.log(`Current state is '${sessionState}'\n`) + if (this.debug && this.printedSessionState.state !== sessionState) { + console.log(`Current session state is '${sessionState}'`) + + this.printedSessionState.state = sessionState + this.printedSessionState.printed = false } // There is an internal error present in SAS Viya 3.5 From 0212b677ae4b95e8dfe9cfe7380be319e3e7294d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 13 Jan 2021 08:03:31 +0000 Subject: [PATCH 3/3] chore(deps): bump @sasjs/utils from 1.5.0 to 2.0.2 Bumps [@sasjs/utils](https://github.com/sasjs/utils) from 1.5.0 to 2.0.2. - [Release notes](https://github.com/sasjs/utils/releases) - [Commits](https://github.com/sasjs/utils/compare/v1.5.0...v2.0.2) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 65afc97..a147e58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1072,9 +1072,9 @@ } }, "@sasjs/utils": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-1.5.0.tgz", - "integrity": "sha512-xKRotDWeCouIebA9GN+eRDFenUZHzn8CRBwqSqi4huLgP/GKtyRpuqBCJ8PYqdvT3q7fBdGM2zHgX+1TNOFEug==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.0.2.tgz", + "integrity": "sha512-FyY/MyeeLP0+OhJWCbiVmV3Mz/mRcrc4oNbw1xhO7CR3DLpiPSmAHaq3sf+1NKCk2AzXbVPqgZM5NVKzvd2wrA==", "requires": { "consola": "^2.15.0", "prompts": "^2.4.0", diff --git a/package.json b/package.json index 929e920..cb62e8f 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ }, "main": "index.js", "dependencies": { - "@sasjs/utils": "^1.5.0", + "@sasjs/utils": "^2.0.2", "es6-promise": "^4.2.8", "form-data": "^3.0.0", "isomorphic-fetch": "^2.2.1"