dart-lang / dart-lang/webdev

Pause on Exceptions in Dart web apps jumps to the wrong location

Open
#2,382 0 comments 0 reactions 0 assignees View on GitHub
P2 package:dwds triaged
Dominant language
Dart
Stars
224
Forks
94
Avg merge
4d 3h
Merged PRs (30d)
2

Description

Given a simple Dart web app created with `dart create -t web` and the code updated to:

```dart
import 'dart:html';

Future main() async {
// TODO: Remove this delay when breakpoints in startup code work
// https://github.com/dart-lang/webdev/issues/830
await Future.delayed(const Duration(seconds: 1));

methodThatThrows();
querySelector('#output')!.text = 'Your Dart app is running.';
}

void methodThatThrows() {
throw Exception("Oops");
}
```

When the exception is triggered, the pause event has the wrong location (line 6, column 16):

```js
{
"jsonrpc": "2.0",
"method": "streamNotify",
"params": {
"streamId": "Debug",
"event": {
"type": "Event",
"kind": "PauseInterrupted",
"timestamp": 1709810801870,
"isolate": {
"type": "@Isolate",
"id": "1",
"number": "1",
"name": "main()",
"isSystemIsolate": false,
"isolateGroupId": ""
},
"topFrame": {
"type": "Frame",
"index": 21,
"code": {
"type": "@Code",
"id": "3",
"name": "main$",
"kind": "Dart"
},
"location": {
"type": "SourceLocation",
"script": {
"type": "@Script",
"id": "2",
"uri": "org-dartlang-app:///web/main.dart"
},
"tokenPos": 1339,
"line": 6,
"column": 16
},
"kind": "AsyncCausal"
}
}
}
}
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with a Dart web app created using `dart create -t web` and the provided `web/main.dart` code. Inspect the `PauseInterrupted` event's `topFrame.location` and compare it with the thrown exception; done means the pause location identifies the correct Dart source position rather than line 6, column 16.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.