Skip to content

Commit

Permalink
Merge pull request #5886 from Countly/SER-2247-system-utility-namespa…
Browse files Browse the repository at this point in the history
…ce-not-found-is-thrown-on-initial-profiler-run

[system-utility] NamespaceNotFound is thrown on initial profiler run
  • Loading branch information
coskunaydinoglu authored Dec 27, 2024
2 parents c86288e + b6c1a98 commit 3102dfb
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions plugins/system-utility/api/system.utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,23 @@ async function stopProfiler(processName) {
const errors = [];

// clear old files
await new Promise(
(res, rej) => countlyFs.gridfs.deleteAll(
PROFILER_DIR,
null,
err => err ? rej(err) : res()
)
);
try {
await new Promise(
(res, rej) => countlyFs.gridfs.deleteAll(
PROFILER_DIR,
null,
err => err ? rej(err) : res()
)
);
}
catch (err) {
if (err.code === 26) { // NamespaceNotFound: thrown when there's no collection initially
// do nothing...
}
else {
throw err;
}
}

// coverage
try {
Expand Down

0 comments on commit 3102dfb

Please sign in to comment.