1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-04 11:10:05 +00:00

Merge pull request #209 from sasjs/job-status-fix

feat(*): improved session and job logging
This commit is contained in:
Yury Shkoda
2021-01-12 17:53:25 +03:00
committed by GitHub
2 changed files with 23 additions and 9 deletions

View File

@@ -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<string>(
`${this.serverUrl}${stateLink.href}?_action=wait&wait=30`,
{
@@ -1126,10 +1125,16 @@ export class SASViyaApiClient {
)
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++
if (pollCount >= MAX_POLL_COUNT) {
resolve(postedJobState)
}

View File

@@ -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<string>(
@@ -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