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

Catch errors when calculating frames in the stack trace #2408

Merged
merged 6 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Catch errors why calculating frames
  • Loading branch information
elliette committed Apr 16, 2024
commit 364b095359efe555680a9921940376edc67a225e
8 changes: 7 additions & 1 deletion dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,13 @@ class Debugger extends Domain {

// Don't populate variables for async frames.
if (populateVariables) {
dartFrame.vars = await variablesFor(frame);
try {
dartFrame.vars = await variablesFor(frame);
} catch (e) {
logger.warning(
'Error calculating Dart variables for frame $frameIndex: $e',
);
}
}

return dartFrame;
Expand Down
21 changes: 15 additions & 6 deletions dwds/lib/src/debugging/frame_computer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ class FrameComputer {
Future<void> _collectSyncFrames({int? limit}) async {
while (_frameIndex < _callFrames.length) {
if (limit != null && _computedFrames.length == limit) return;

final callFrame = _callFrames[_frameIndex];
final dartFrame =
await debugger.calculateDartFrameFor(callFrame, _frameIndex++);
if (dartFrame != null) {
_computedFrames.add(dartFrame);
try {
final callFrame = _callFrames[_frameIndex];
final dartFrame =
await debugger.calculateDartFrameFor(callFrame, _frameIndex++);
if (dartFrame != null) {
_computedFrames.add(dartFrame);
}
} catch (_) {
// If there is an error calculating the frame, then skip it.
}
}
}
Expand Down Expand Up @@ -93,6 +96,7 @@ class FrameComputer {
final asyncFramesToProcess = _asyncFramesToProcess!;
// Process a single async frame.
if (asyncFramesToProcess.isNotEmpty) {
try {
final callFrame = asyncFramesToProcess.removeAt(0);
final location = WipLocation.fromValues(
callFrame.scriptId,
Expand All @@ -116,6 +120,11 @@ class FrameComputer {
frame.kind = FrameKind.kAsyncCausal;
_computedFrames.add(frame);
}


} catch (_) {
// If there is an error calculating the frame, then skip it.
}
}
}

Expand Down