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

assert() shows opaque error #1966

Closed
johnpryan opened this issue Jul 22, 2021 · 6 comments
Closed

assert() shows opaque error #1966

johnpryan opened this issue Jul 22, 2021 · 6 comments
Labels
closed-stale Closed as the issue or PR is assumed stale. P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Milestone

Comments

@johnpryan
Copy link
Contributor

johnpryan commented Jul 22, 2021

When an assert() statement fails, "Script error." appears in the console.

We should investigate if assert statements should be enabled in DartPad, and how to display a more helpful error.

Related issues:

@johnpryan johnpryan added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Jul 22, 2021
@johnpryan johnpryan self-assigned this Jul 22, 2021
@johnpryan johnpryan added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Jul 22, 2021
@RedBrogdon RedBrogdon added this to the Backlog milestone Jul 29, 2021
@johnpryan johnpryan modified the milestones: Backlog, On Deck Oct 20, 2021
@johnpryan
Copy link
Contributor Author

Here's an updated example - this was filed before the framework was updated to null safety, so most of the asserts in the framework can't be hit anymore.

@johnpryan
Copy link
Contributor Author

Filed flutter/flutter#92191 to track unnecessary asserts in the SDK

@nshahan
Copy link

nshahan commented Oct 25, 2021

I can see the assertion failure message appear in the browser DevTools console. Is this just a matter of surfacing those messages in the DartPad console?

@johnpryan
Copy link
Contributor Author

johnpryan commented Oct 25, 2021

Yes that would help. We should probably show the red error widget too. I'm not sure if dart-archive/dart-services#737 would help with that, or if the issue is just how the frontend is handling the error.

@johnpryan
Copy link
Contributor Author

johnpryan commented Oct 26, 2021

Gathered a bit more on this: the assertion failure in the example should be one of the VisualDensity constructor's asserts, but the assertion that triggers is:

errors.dart:202 Uncaught Error: Assertion failed: file:///Users/brettmorgan/Documents/GitHub/dart-services/flutter-sdk/packages/flutter/lib/src/widgets/framework.dart:2577:20
_debugCurrentBuildTarget == context
is not true
    at Object.throw_ [as throw] (errors.dart:251)
    at Object.assertFailed (errors.dart:29)
    at framework.dart:2577
    at framework.BuildOwner.new.buildScope (framework.dart:2580)
    at RenderObjectToWidgetAdapter.new.attachToRenderTree (binding.dart:1111)
    at binding$.WidgetsFlutterBinding.new.attachRootWidget (binding.dart:943)
    at binding.dart:924
    at internalCallback (isolate_helper.dart:48)

Here's the line where the assert is defined: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/framework.dart#L2535

This is happening on the dart-services master branch and dart-archive/dart-services#737.

@parlough
Copy link
Member

Consolidating issue in to #3008 alongside other error surfacing improvements. Thanks for the discussion and investigation here!

@parlough parlough closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2024
@parlough parlough added the closed-stale Closed as the issue or PR is assumed stale. label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-stale Closed as the issue or PR is assumed stale. P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants