Skip to content

Commit 3102dfb

Browse files
Merge pull request #5886 from Countly/SER-2247-system-utility-namespace-not-found-is-thrown-on-initial-profiler-run
[system-utility] NamespaceNotFound is thrown on initial profiler run
2 parents c86288e + b6c1a98 commit 3102dfb

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)