Skip to content

Commit b6c1a98

Browse files
author
Cihad Tekin
committed
[system-utility] NamespaceNotFound is thrown when profiler gets run for the first time
1 parent c86288e commit b6c1a98

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

plugins/system-utility/api/system.utility.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,23 @@ async function stopProfiler(processName) {
471471
const errors = [];
472472

473473
// clear old files
474-
await new Promise(
475-
(res, rej) => countlyFs.gridfs.deleteAll(
476-
PROFILER_DIR,
477-
null,
478-
err => err ? rej(err) : res()
479-
)
480-
);
474+
try {
475+
await new Promise(
476+
(res, rej) => countlyFs.gridfs.deleteAll(
477+
PROFILER_DIR,
478+
null,
479+
err => err ? rej(err) : res()
480+
)
481+
);
482+
}
483+
catch (err) {
484+
if (err.code === 26) { // NamespaceNotFound: thrown when there's no collection initially
485+
// do nothing...
486+
}
487+
else {
488+
throw err;
489+
}
490+
}
481491

482492
// coverage
483493
try {

0 commit comments

Comments
 (0)