Skip to content

Commit

Permalink
chore(server): handle get metering data error (labring#1650)
Browse files Browse the repository at this point in the history
  • Loading branch information
0fatal authored Nov 8, 2023
1 parent b3bc612 commit 5706a3d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions server/src/billing/billing-creation-task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ export class BillingCreationTaskService {
app,
nextMeteringTime,
)
if (!meteringData) {
this.logger.warn(`No metering data found for application: ${appid}`)
return
}

// get application bundle
const bundle = await this.bundleService.findOne(appid)
Expand Down
10 changes: 9 additions & 1 deletion server/src/billing/billing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,15 @@ export class BillingService {
.then((res) => res.result[0])
.then((res) => Number(res.value.value))

const [cpu, memory] = await Promise.all([cpuTask, memoryTask])
let error = false

const [cpu, memory] = await Promise.all([cpuTask, memoryTask]).catch(() => {
error = true
return [0, 0]
})
if (error) {
return null
}

return {
cpu,
Expand Down

0 comments on commit 5706a3d

Please sign in to comment.