diff --git a/CHANGELOG.md b/CHANGELOG.md index 20c554f4b7e..4eaecbece72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Fixes: - [core] Fixed a bug causing events to not being loaded when there's an escaped character in the event name - [gridfs] fixes for moving to Promises +- [system-utility] Fixed: Mongo error (code: 26) in some Countly instances when the profiler gets run for the first time - [surveys] "Select one" text in the widget can be edited now Dependencies: diff --git a/plugins/system-utility/api/api.js b/plugins/system-utility/api/api.js index f5e956ea63c..6711909080f 100644 --- a/plugins/system-utility/api/api.js +++ b/plugins/system-utility/api/api.js @@ -209,12 +209,17 @@ function stopWithTimeout(type, fromTimeout = false) { validate(params, async() => { try { const tarStream = await systemUtility.profilerFilesTarStream(); - params.res.writeHead(200, { - "Content-Type": "plain/text; charset=utf-8", - "Content-Disposition": "attachment; filename=profiler.tar" - }); - tarStream.on("end", () => params.res.end()); - tarStream.pipe(params.res); + if (tarStream === null) { + common.returnMessage(params, 404, "Profiler files not found"); + } + else { + params.res.writeHead(200, { + "Content-Type": "plain/text; charset=utf-8", + "Content-Disposition": "attachment; filename=profiler.tar" + }); + tarStream.on("end", () => params.res.end()); + tarStream.pipe(params.res); + } } catch (err) { log.e(err);