webdev icon indicating copy to clipboard operation
webdev copied to clipboard

Breakpoints break in wrong location in unnamed extensions: FrameComputer: Error calculating sync frame: RangeError (end): Invalid value: Not in inclusive range 15..26: 10

Open DanTup opened this issue 1 year ago • 0 comments

This was originally raised at https://github.com/Dart-Code/Dart-Code/issues/5394 by @markbeij.

Breakpoints in unnamed extensions don't seem to work on web, instead execution pauses on the parent frame and an error is printed:

FrameComputer: Error calculating sync frame: RangeError (end): Invalid value: Not in inclusive range 15..26: 10

The message appears to come from here:

https://github.com/dart-lang/webdev/blob/4a92ba588ab70f34d45bbeb3eeada3079fedf690/dwds/lib/src/debugging/frame_computer.dart#L73

Here I have a breakpoint on line 20 (return this) but execution paused at the parent frame:

Image

Example code:

import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(body: Center(child: Text(''.myExtension()))),
    );
  }
}

extension on String {
  String myExtension() {
    return this; // Breakpoint on this line
  }
}

DanTup avatar Jan 21 '25 16:01 DanTup