Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHARD-1749 - Crash fix. #368

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/reporter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,20 @@ class Reporter {

// Sends a report
async _sendReport(data) {
if (logFlags.debug) this.mainLogger.debug(JSON.stringify({method: '_sendReport', script: 'reporter/index', hasRecipient: this.hasRecipient}))
if (logFlags.debug) this.mainLogger.debug(Utils.safeStringify({method: '_sendReport', script: 'reporter/index', hasRecipient: this.hasRecipient}))
if (!this.hasRecipient) {
return
}
const nodeId = Self.id
if (logFlags.debug) this.mainLogger.debug(JSON.stringify({method: '_sendReport', script: 'reporter/index', nodeId: nodeId}))
if (logFlags.debug) this.mainLogger.debug(Utils.safeStringify({method: '_sendReport', script: 'reporter/index', nodeId: nodeId}))
if (!nodeId) throw new Error('No node ID available to the Reporter module.')
const report = {
nodeId,
data,
}
if (logFlags.debug){
try {
this.mainLogger.debug(JSON.stringify({report: JSON.stringify(report), method: `_sendReport`, script: '_sendReport'}))
this.mainLogger.debug(Utils.safeStringify({report: Utils.safeStringify(report), method: `_sendReport`, script: '_sendReport'}))
} catch (error){
console.error(`[reporter/index][_sendReport] ERROR while writing report object to log.`, error)
}
Expand Down Expand Up @@ -256,7 +256,7 @@ class Reporter {
? await this.stateManager.transactionQueue.getAccountsStateHash()
: allZeroes64
*/
if (logFlags.debug) this.mainLogger.debug(JSON.stringify({method: 'report', script: 'reporter/index', cycleChainNewest: CycleChain.newest}))
if (logFlags.debug) this.mainLogger.debug(Utils.safeStringify({method: 'report', script: 'reporter/index', cycleChainNewest: CycleChain.newest}))
if (CycleChain.newest == null) {
this.restartReportInterval()
return
Expand Down Expand Up @@ -415,7 +415,7 @@ class Reporter {
clearTimeout(this.reportTimer)
}
const reportInterval = this.getReportInterval()
if (logFlags.debug) this.mainLogger.debug(JSON.stringify({script: 'reporter/index', method: 'restartReportInterval', reportInterval}))
if (logFlags.debug) this.mainLogger.debug(Utils.safeStringify({script: 'reporter/index', method: 'restartReportInterval', reportInterval}))
this.reportTimer = setTimeout(() => {
this.report()
}, reportInterval)
Expand All @@ -424,12 +424,12 @@ class Reporter {
startReporting() {
const self = this

if (logFlags.debug) this.mainLogger.debug(JSON.stringify({script: 'reporter/index', method: 'startReporting', reportingIntervalDefined: (this.reportingInterval !== undefined)}))
if (logFlags.debug) this.mainLogger.debug(Utils.safeStringify({script: 'reporter/index', method: 'startReporting', reportingIntervalDefined: (this.reportingInterval !== undefined)}))
if (this.reportingInterval) {
return
}
this.reportingInterval = setInterval(() => {
if (logFlags.debug) this.mainLogger.debug(JSON.stringify({script: 'reporter/index', method: 'startReporting[reportingInterval]', message: 'called'}))
if (logFlags.debug) this.mainLogger.debug(Utils.safeStringify({script: 'reporter/index', method: 'startReporting[reportingInterval]', message: 'called'}))
self.collectStatisticToReport()

//temp mem debugging:
Expand All @@ -438,7 +438,7 @@ class Reporter {

//log a socket report every 5 minutes
this.socketReportInterval = setInterval(async () => {
if (logFlags.debug) this.mainLogger.debug(JSON.stringify({script: 'reporter/index', method: 'startReporting[socketReportInterval]', logSocketReports: this.config.logSocketReports}))
if (logFlags.debug) this.mainLogger.debug(Utils.safeStringify({script: 'reporter/index', method: 'startReporting[socketReportInterval]', logSocketReports: this.config.logSocketReports}))
if (this.config.logSocketReports) {
const report = await getSocketReport()
this.mainLogger.info(Utils.safeStringify(report))
Expand Down Expand Up @@ -478,7 +478,7 @@ class Reporter {
}

stopReporting() {
if (logFlags.debug) this.mainLogger.debug(JSON.stringify({script: 'reporter/index', method: 'stopReporting', message: 'called'}))
if (logFlags.debug) this.mainLogger.debug(Utils.safeStringify({script: 'reporter/index', method: 'stopReporting', message: 'called'}))
this.mainLogger.info('Stopping statistics reporting...')
clearTimeout(this.reportTimer)
clearInterval(this.reportingInterval)
Expand Down
Loading