mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-05 19:50:06 +00:00
fix: log capture if job fails, test framework update, added test for log capture
This commit is contained in:
@@ -303,22 +303,8 @@ export class SASViyaApiClient {
|
||||
|
||||
let jobResult, log;
|
||||
|
||||
if (jobStatus === "failed" || jobStatus === "error") {
|
||||
return Promise.reject(currentJob.error);
|
||||
}
|
||||
const resultLink = `/compute/sessions/${executionSessionId}/filerefs/_webout/content`;
|
||||
const logLink = currentJob.links.find((l) => l.rel === "log");
|
||||
|
||||
if (resultLink) {
|
||||
jobResult = await this.request<any>(
|
||||
`${this.serverUrl}${resultLink}`,
|
||||
{ headers },
|
||||
"text"
|
||||
).catch((e) => ({
|
||||
result: JSON.stringify(e),
|
||||
}));
|
||||
}
|
||||
|
||||
if (true && logLink) {
|
||||
log = await this.request<any>(
|
||||
`${this.serverUrl}${logLink.href}/content?limit=10000`,
|
||||
@@ -328,6 +314,21 @@ export class SASViyaApiClient {
|
||||
).then((res: any) => res.result.items.map((i: any) => i.line).join("\n"));
|
||||
}
|
||||
|
||||
if (jobStatus === "failed" || jobStatus === "error") {
|
||||
return Promise.reject({error: currentJob.error, log: log});
|
||||
}
|
||||
const resultLink = `/compute/sessions/${executionSessionId}/filerefs/_webout/content`;
|
||||
|
||||
if (resultLink) {
|
||||
jobResult = await this.request<any>(
|
||||
`${this.serverUrl}${resultLink}`,
|
||||
{ headers },
|
||||
"text"
|
||||
).catch((e) => ({
|
||||
result: JSON.stringify(e),
|
||||
}));
|
||||
}
|
||||
|
||||
await this.sessionManager.clearSession(executionSessionId, accessToken);
|
||||
|
||||
return { result: jobResult?.result, log };
|
||||
|
||||
12
src/SASjs.ts
12
src/SASjs.ts
@@ -579,8 +579,10 @@ export default class SASjs {
|
||||
|
||||
resolve(responseJson);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
if (needsRetry(JSON.stringify(e))) {
|
||||
.catch(async (response) => {
|
||||
let error = response.error || response;
|
||||
|
||||
if (needsRetry(JSON.stringify(error))) {
|
||||
if (this.retryCountComputeApi < requestRetryLimit) {
|
||||
let retryResponse = await this.executeJobViaComputeApi(
|
||||
sasJob,
|
||||
@@ -599,15 +601,17 @@ export default class SASjs {
|
||||
}
|
||||
}
|
||||
|
||||
if (e && e.status === 401) {
|
||||
if (error && error.status === 401) {
|
||||
if (loginRequiredCallback) loginRequiredCallback(true);
|
||||
sasjsWaitingRequest.requestPromise.resolve = resolve;
|
||||
sasjsWaitingRequest.requestPromise.reject = reject;
|
||||
sasjsWaitingRequest.config = config;
|
||||
this.sasjsWaitingRequests.push(sasjsWaitingRequest);
|
||||
} else {
|
||||
reject({ MESSAGE: e || "Job execution failed" });
|
||||
reject({ MESSAGE: error || "Job execution failed" });
|
||||
}
|
||||
|
||||
this.appendSasjsRequest(response.log, sasJob, null);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user