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

Log a single error message when async or sync frame calculation fails #2430

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
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
16 changes: 13 additions & 3 deletions dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Debugger extends Domain {
final Locations _locations;
final SkipLists _skipLists;

int _frameErrorCount = 0;

Debugger._(
this._remoteDebugger,
this._streamNotify,
Expand Down Expand Up @@ -465,15 +467,23 @@ class Debugger extends Domain {
try {
dartFrame.vars = await variablesFor(frame);
} catch (e) {
logger.warning(
'Error calculating Dart variables for frame $frameIndex: $e',
);
_frameErrorCount++;
}
}

return dartFrame;
}

/// Can be called after [calculateDartFrameFor] to log any errors.
void logAnyFrameErrors({required String frameType}) {
if (_frameErrorCount > 0) {
logger.warning(
'Error calculating Dart variables for $_frameErrorCount $frameType frames.',
);
}
_frameErrorCount = 0;
}

void _scriptParsedHandler(ScriptParsedEvent e) {
final scriptPath = _pathForChromeScript(e.script.url);
if (scriptPath != null) {
Expand Down
2 changes: 2 additions & 0 deletions dwds/lib/src/debugging/frame_computer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class FrameComputer {
logger.warning('Error calculating sync frame: $e');
}
}
debugger.logAnyFrameErrors(frameType: 'sync');
}

Future<void> _collectAsyncFrames({int? limit}) async {
Expand Down Expand Up @@ -129,6 +130,7 @@ class FrameComputer {
logger.warning('Error calculating async frame: $e');
}
}
debugger.logAnyFrameErrors(frameType: 'async');
}

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