mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 12:30:06 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c30cbff13 | ||
|
|
8f3a7f33f8 | ||
|
|
67ec27bab7 | ||
|
|
c1b200b0d8 | ||
|
|
e03ec996d6 | ||
|
|
ad8dbfd4ec | ||
|
|
15a774ff81 | ||
|
|
98114c5591 |
@@ -1078,6 +1078,7 @@ export class SASViyaApiClient {
|
|||||||
) {
|
) {
|
||||||
let POLL_INTERVAL = 300
|
let POLL_INTERVAL = 300
|
||||||
let MAX_POLL_COUNT = 1000
|
let MAX_POLL_COUNT = 1000
|
||||||
|
let MAX_ERROR_COUNT = 5
|
||||||
|
|
||||||
if (pollOptions) {
|
if (pollOptions) {
|
||||||
POLL_INTERVAL = pollOptions.POLL_INTERVAL || POLL_INTERVAL
|
POLL_INTERVAL = pollOptions.POLL_INTERVAL || POLL_INTERVAL
|
||||||
@@ -1086,6 +1087,7 @@ export class SASViyaApiClient {
|
|||||||
|
|
||||||
let postedJobState = ''
|
let postedJobState = ''
|
||||||
let pollCount = 0
|
let pollCount = 0
|
||||||
|
let errorCount = 0
|
||||||
const headers: any = {
|
const headers: any = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'If-None-Match': etag
|
'If-None-Match': etag
|
||||||
@@ -1107,7 +1109,11 @@ export class SASViyaApiClient {
|
|||||||
this.debug
|
this.debug
|
||||||
)
|
)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
throw prefixMessage(err, 'Error while getting job state. ')
|
console.error(
|
||||||
|
`Error fetching job state from ${this.serverUrl}${stateLink.href}. Starting poll, assuming job to be running.`,
|
||||||
|
err
|
||||||
|
)
|
||||||
|
return { result: 'unavailable' }
|
||||||
})
|
})
|
||||||
|
|
||||||
const currentState = state.trim()
|
const currentState = state.trim()
|
||||||
@@ -1122,7 +1128,8 @@ export class SASViyaApiClient {
|
|||||||
if (
|
if (
|
||||||
postedJobState === 'running' ||
|
postedJobState === 'running' ||
|
||||||
postedJobState === '' ||
|
postedJobState === '' ||
|
||||||
postedJobState === 'pending'
|
postedJobState === 'pending' ||
|
||||||
|
postedJobState === 'unavailable'
|
||||||
) {
|
) {
|
||||||
if (stateLink) {
|
if (stateLink) {
|
||||||
const { result: jobState } = await this.requestClient
|
const { result: jobState } = await this.requestClient
|
||||||
@@ -1134,13 +1141,27 @@ export class SASViyaApiClient {
|
|||||||
this.debug
|
this.debug
|
||||||
)
|
)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
throw prefixMessage(
|
errorCount++
|
||||||
err,
|
if (
|
||||||
'Error while getting job state after interval. '
|
pollCount >= MAX_POLL_COUNT ||
|
||||||
|
errorCount >= MAX_ERROR_COUNT
|
||||||
|
) {
|
||||||
|
throw prefixMessage(
|
||||||
|
err,
|
||||||
|
'Error while getting job state after interval. '
|
||||||
|
)
|
||||||
|
}
|
||||||
|
console.error(
|
||||||
|
`Error fetching job state from ${this.serverUrl}${stateLink.href}. Resuming poll, assuming job to be running.`,
|
||||||
|
err
|
||||||
)
|
)
|
||||||
|
return { result: 'unavailable' }
|
||||||
})
|
})
|
||||||
|
|
||||||
postedJobState = jobState.trim()
|
postedJobState = jobState.trim()
|
||||||
|
if (postedJobState != 'unavailable' && errorCount > 0) {
|
||||||
|
errorCount = 0
|
||||||
|
}
|
||||||
|
|
||||||
if (this.debug && printedState !== postedJobState) {
|
if (this.debug && printedState !== postedJobState) {
|
||||||
console.log('Polling job status...')
|
console.log('Polling job status...')
|
||||||
|
|||||||
Reference in New Issue
Block a user