Skip to content

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

Open
@DanTup

Description

@DanTup

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

import 'dart:html';

Future<void> 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):

{
	"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"
			}
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onpackage:dwdstriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions