diff --git a/lib/utils/report-utils.js b/lib/utils/report-utils.js --- a/lib/utils/report-utils.js +++ b/lib/utils/report-utils.js @@ -13,18 +13,29 @@ return useSelector(state => state.reportStore.enabledReports[reportType]); } +// maximum size of reports without std::string overhead +const MAX_REPORT_LENGTH = 200_000_000 - 90000; +function isReportSizeValid(report: ClientReportCreationRequest): boolean { + try { + return JSON.stringify(report).length < MAX_REPORT_LENGTH; + } catch (e) { + return false; + } +} + function isReportEnabled( report: ClientReportCreationRequest, enabledReports: EnabledReports, ): boolean { - return ( + const isReportTypeEnabled = (report.type === reportTypes.MEDIA_MISSION && enabledReports.mediaReports) || (report.type === reportTypes.ERROR && enabledReports.crashReports) || ((report.type === reportTypes.ENTRY_INCONSISTENCY || report.type === reportTypes.THREAD_INCONSISTENCY) && - enabledReports.inconsistencyReports) - ); + enabledReports.inconsistencyReports); + + return isReportTypeEnabled && isReportSizeValid(report); } function generateReportID(): string {