diff --git a/service/src/presenters/functionInvocation.ts b/service/src/presenters/functionInvocation.ts index 19c63d8..b314ad8 100644 --- a/service/src/presenters/functionInvocation.ts +++ b/service/src/presenters/functionInvocation.ts @@ -15,14 +15,16 @@ export let functionInvocationPresenter = ( error: invocation.error, - logs: invocation.logs.split('\n').map(line => { - let [ts, message] = JSON.parse(line); - - return { - timestamp: ts, - message - }; - }), + logs: !invocation.logs + ? [] + : invocation.logs.split('\n').map(line => { + let [ts, message] = JSON.parse(line); + + return { + timestamp: ts, + message + }; + }), createdAt: invocation.createdAt }); diff --git a/service/src/providers/aws-lambda/invoke.ts b/service/src/providers/aws-lambda/invoke.ts index 46f6699..5d7e448 100644 --- a/service/src/providers/aws-lambda/invoke.ts +++ b/service/src/providers/aws-lambda/invoke.ts @@ -54,6 +54,8 @@ export let invokeFunction = async (d: { billedTimeMs: -1 }; + let startTs = Date.now(); + try { res = await lambdaClient.send( new InvokeCommand({ @@ -98,7 +100,7 @@ export let invokeFunction = async (d: { let finalLogs: [number, string][] = []; if (requestId) { - let currentTimestamp = 0; + let currentTimestamp = startTs; for (let i = 0; i < productiveLogs.length; i++) { let line = productiveLogs[i]; if (!line) continue; @@ -108,7 +110,7 @@ export let invokeFunction = async (d: { if (!ts || !rest) continue; currentTimestamp = new Date(ts.trim()).getTime(); - line = rest.trim().replace('\tERROR', '').replace('\tINFO', ''); + line = rest.trim().replace('ERROR\t', '').replace('INFO\t', ''); } finalLogs.push([currentTimestamp, line]); diff --git a/service/src/services/functionDeployment.ts b/service/src/services/functionDeployment.ts index 697db1e..e502f61 100644 --- a/service/src/services/functionDeployment.ts +++ b/service/src/services/functionDeployment.ts @@ -142,14 +142,16 @@ class functionDeploymentServiceImpl { startedAt: s.startedAt, endedAt: s.endedAt, - logs: s.output.split('\n').map(line => { - let [ts, message] = JSON.parse(line); - - return { - timestamp: ts, - message - }; - }) + logs: !s.output + ? [] + : s.output.split('\n').map(line => { + let [ts, message] = JSON.parse(line); + + return { + timestamp: ts, + message + }; + }) })) ] };