mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
chore: bug fixes for session crash details + return code
This commit is contained in:
@@ -1021,7 +1021,7 @@ paths:
|
||||
type: string
|
||||
example: /Public/somefolder/some.file
|
||||
requestBody:
|
||||
required: true
|
||||
required: false
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
|
||||
@@ -74,11 +74,13 @@ ${program}`
|
||||
await moveFile(codePath + '.bkp', codePath)
|
||||
|
||||
// we now need to poll the session array
|
||||
while (!session.completed || !session.crashed) {
|
||||
while (!session.completed) {
|
||||
await delay(50)
|
||||
}
|
||||
|
||||
const log = (await fileExists(logPath)) ? await readFile(logPath) : ''
|
||||
const log =
|
||||
((await fileExists(logPath)) ? await readFile(logPath) : '') +
|
||||
session.crashed
|
||||
const webout = (await fileExists(weboutPath))
|
||||
? await readFile(weboutPath)
|
||||
: ''
|
||||
|
||||
@@ -83,7 +83,7 @@ export class SessionController {
|
||||
})
|
||||
.catch((err) => {
|
||||
session.completed = true
|
||||
session.crashed = true
|
||||
session.crashed = err.toString()
|
||||
console.log('session crashed', session.id, err)
|
||||
})
|
||||
|
||||
@@ -100,7 +100,9 @@ export class SessionController {
|
||||
public async waitForSession(session: Session) {
|
||||
const codeFilePath = path.join(session.path, 'code.sas')
|
||||
|
||||
while (await fileExists(codeFilePath)) {}
|
||||
// TODO: don't wait forever
|
||||
while ((await fileExists(codeFilePath)) && !session.crashed) {}
|
||||
console.log('session crashed?', !!session.crashed, session.crashed)
|
||||
|
||||
session.ready = true
|
||||
return Promise.resolve(session)
|
||||
|
||||
@@ -64,10 +64,10 @@ export class STPController {
|
||||
@Post('/execute')
|
||||
public async executeReturnJson(
|
||||
@Request() request: express.Request,
|
||||
@Body() body: ExecuteReturnJsonPayload,
|
||||
@Body() body?: ExecuteReturnJsonPayload,
|
||||
@Query() _program?: string
|
||||
): Promise<ExecuteReturnJsonResponse> {
|
||||
const program = _program ?? body._program
|
||||
const program = _program ?? body?._program
|
||||
return executeReturnJson(request, program!)
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,7 @@ const executeReturnJson = async (
|
||||
}
|
||||
} catch (err: any) {
|
||||
throw {
|
||||
code: 400,
|
||||
status: 'failure',
|
||||
message: 'Job execution failed.',
|
||||
error: typeof err === 'object' ? err.toString() : err
|
||||
|
||||
@@ -30,10 +30,9 @@ stpRouter.post(
|
||||
fileUploadController.getMulterUploadObject().any(),
|
||||
async (req: any, res: any) => {
|
||||
const { error: errQ, value: query } = executeProgramRawValidation(req.query)
|
||||
if (errQ) return res.status(400).send(errQ.details[0].message)
|
||||
|
||||
const { error: errB, value: body } = executeProgramRawValidation(req.body)
|
||||
if (errB) return res.status(400).send(errB.details[0].message)
|
||||
|
||||
if (errQ && errB) return res.status(400).send(errB.details[0].message)
|
||||
|
||||
try {
|
||||
const response = await controller.executeReturnJson(
|
||||
|
||||
@@ -6,5 +6,5 @@ export interface Session {
|
||||
path: string
|
||||
inUse: boolean
|
||||
completed: boolean
|
||||
crashed?: boolean
|
||||
crashed?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user