Skip to content

Commit

Permalink
feat(save-project-api): print uploaded payload size
Browse files Browse the repository at this point in the history
  • Loading branch information
tomastrajan committed Mar 21, 2023
1 parent 2f79470 commit 93678b9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/tasks/save-project-api.task.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ListrTask } from 'listr2';

import { Context } from '../interface';
import * as api from '../services/api.service';
import { Context } from '../interface';
import { getHumanReadableFileSize } from '../services/fs.service';

export const saveProjectApiTask: ListrTask = {
title: 'Save project results (Omniboard.dev)',
Expand All @@ -18,7 +19,11 @@ export const saveProjectApiTask: ListrTask = {
},
task: async (ctx, task) => {
// try to prevent OOM in case of large result
await new Promise<void>((resolve) => setTimeout(() => resolve(), 100));
return api.uploadProject(ctx.results);
await new Promise<void>((resolve) => setTimeout(() => resolve(), 200));
return api.uploadProject(ctx.results).then(() => {
task.title = `${task.title} successful, ${getHumanReadableFileSize(
Buffer.byteLength(JSON.stringify(ctx.results), 'utf8')
)}`;
});
},
};

0 comments on commit 93678b9

Please sign in to comment.