Skip to content

Commit fc32eb6

Browse files
authored
Collect log message count and log at the end (#2430)
1 parent 99abc53 commit fc32eb6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

dwds/lib/src/debugging/debugger.dart

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class Debugger extends Domain {
5454
final Locations _locations;
5555
final SkipLists _skipLists;
5656

57+
int _frameErrorCount = 0;
58+
5759
Debugger._(
5860
this._remoteDebugger,
5961
this._streamNotify,
@@ -465,15 +467,23 @@ class Debugger extends Domain {
465467
try {
466468
dartFrame.vars = await variablesFor(frame);
467469
} catch (e) {
468-
logger.warning(
469-
'Error calculating Dart variables for frame $frameIndex: $e',
470-
);
470+
_frameErrorCount++;
471471
}
472472
}
473473

474474
return dartFrame;
475475
}
476476

477+
/// Can be called after [calculateDartFrameFor] to log any errors.
478+
void logAnyFrameErrors({required String frameType}) {
479+
if (_frameErrorCount > 0) {
480+
logger.warning(
481+
'Error calculating Dart variables for $_frameErrorCount $frameType frames.',
482+
);
483+
}
484+
_frameErrorCount = 0;
485+
}
486+
477487
void _scriptParsedHandler(ScriptParsedEvent e) {
478488
final scriptPath = _pathForChromeScript(e.script.url);
479489
if (scriptPath != null) {

dwds/lib/src/debugging/frame_computer.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class FrameComputer {
7373
logger.warning('Error calculating sync frame: $e');
7474
}
7575
}
76+
debugger.logAnyFrameErrors(frameType: 'sync');
7677
}
7778

7879
Future<void> _collectAsyncFrames({int? limit}) async {
@@ -129,6 +130,7 @@ class FrameComputer {
129130
logger.warning('Error calculating async frame: $e');
130131
}
131132
}
133+
debugger.logAnyFrameErrors(frameType: 'async');
132134
}
133135

134136
// Async frames are no longer on the stack - we don't have local variable

0 commit comments

Comments
 (0)