1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-25 15:01:20 +00:00

Merge branch 'master' into dependabot/npm_and_yarn/webpack-5.13.0

This commit is contained in:
Yury Shkoda
2021-01-13 12:16:49 +03:00
committed by GitHub
4 changed files with 27 additions and 13 deletions

6
package-lock.json generated
View File

@@ -1072,9 +1072,9 @@
} }
}, },
"@sasjs/utils": { "@sasjs/utils": {
"version": "1.5.0", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-1.5.0.tgz", "resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.0.2.tgz",
"integrity": "sha512-xKRotDWeCouIebA9GN+eRDFenUZHzn8CRBwqSqi4huLgP/GKtyRpuqBCJ8PYqdvT3q7fBdGM2zHgX+1TNOFEug==", "integrity": "sha512-FyY/MyeeLP0+OhJWCbiVmV3Mz/mRcrc4oNbw1xhO7CR3DLpiPSmAHaq3sf+1NKCk2AzXbVPqgZM5NVKzvd2wrA==",
"requires": { "requires": {
"consola": "^2.15.0", "consola": "^2.15.0",
"prompts": "^2.4.0", "prompts": "^2.4.0",

View File

@@ -58,7 +58,7 @@
}, },
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {
"@sasjs/utils": "^1.5.0", "@sasjs/utils": "^2.0.2",
"es6-promise": "^4.2.8", "es6-promise": "^4.2.8",
"form-data": "^3.0.0", "form-data": "^3.0.0",
"isomorphic-fetch": "^2.2.1" "isomorphic-fetch": "^2.2.1"

View File

@@ -1107,6 +1107,8 @@ export class SASViyaApiClient {
} }
return new Promise(async (resolve, _) => { return new Promise(async (resolve, _) => {
let printedState = ''
const interval = setInterval(async () => { const interval = setInterval(async () => {
if ( if (
postedJobState === 'running' || postedJobState === 'running' ||
@@ -1114,9 +1116,6 @@ export class SASViyaApiClient {
postedJobState === 'pending' postedJobState === 'pending'
) { ) {
if (stateLink) { if (stateLink) {
if (this.debug) {
console.log('Polling job status... \n')
}
const { result: jobState } = await this.request<string>( const { result: jobState } = await this.request<string>(
`${this.serverUrl}${stateLink.href}?_action=wait&wait=30`, `${this.serverUrl}${stateLink.href}?_action=wait&wait=30`,
{ {
@@ -1126,10 +1125,16 @@ export class SASViyaApiClient {
) )
postedJobState = jobState.trim() postedJobState = jobState.trim()
if (this.debug) {
console.log(`Current state: ${postedJobState}\n`) if (this.debug && printedState !== postedJobState) {
console.log('Polling job status...')
console.log(`Current job state: ${postedJobState}`)
printedState = postedJobState
} }
pollCount++ pollCount++
if (pollCount >= MAX_POLL_COUNT) { if (pollCount >= MAX_POLL_COUNT) {
resolve(postedJobState) resolve(postedJobState)
} }

View File

@@ -23,6 +23,10 @@ export class SessionManager {
private currentContext: Context | null = null private currentContext: Context | null = null
private csrfToken: CsrfToken | null = null private csrfToken: CsrfToken | null = null
private _debug: boolean = false private _debug: boolean = false
private printedSessionState = {
printed: false,
state: ''
}
public get debug() { public get debug() {
return this._debug return this._debug
@@ -175,8 +179,10 @@ export class SessionManager {
sessionState === '' sessionState === ''
) { ) {
if (stateLink) { if (stateLink) {
if (this.debug) { if (this.debug && !this.printedSessionState.printed) {
console.log('Polling session status... \n') console.log('Polling session status...')
this.printedSessionState.printed = true
} }
const { result: state } = await this.requestSessionStatus<string>( const { result: state } = await this.requestSessionStatus<string>(
@@ -191,8 +197,11 @@ export class SessionManager {
sessionState = state.trim() sessionState = state.trim()
if (this.debug) { if (this.debug && this.printedSessionState.state !== sessionState) {
console.log(`Current state is '${sessionState}'\n`) 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 // There is an internal error present in SAS Viya 3.5