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

build_test fails with an out-of-call-stack exception with build_resolvers 1.3.1 #2596

Closed
kevmoo opened this issue Jan 14, 2020 · 7 comments · Fixed by #2599
Closed

build_test fails with an out-of-call-stack exception with build_resolvers 1.3.1 #2596

kevmoo opened this issue Jan 14, 2020 · 7 comments · Fixed by #2599
Labels
package:build_test type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@kevmoo
Copy link
Member

kevmoo commented Jan 14, 2020

build_resolvers: 1.3.1
build_test: 0.10.11

See commit b6fdcb0

This is the failing test:

https://github.com/kevmoo/source_gen_test/blob/c1aff801cba9f46c27a1da854fbeed75fb7b2a1e/test/init_library_reader_test.dart#L54-L62

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) package:build_test labels Jan 14, 2020
kevmoo added a commit to kevmoo/source_gen_test that referenced this issue Jan 14, 2020
@jakemac53
Copy link
Contributor

@kevmoo
Copy link
Member Author

kevmoo commented Jan 14, 2020

https://github.com/dart-lang/build/blob/master/build_test/lib/src/resolve_source.dart#L197 😢

I tried just awaiting that – still has the problem!

@jakemac53
Copy link
Contributor

Awaiting that fixes the issue but then the test has to be updated to expect the new exception type (which is the documented one, previously it threw a different one). I think it might be breaking for other use cases though to await there, I need to look into it a bit more.

cc @matanlurey

@jakemac53
Copy link
Contributor

Ya if we awaited there we would block on the tearDown future being resolved so this would just hang tests that use that.

I don't really know what the correct solution is going to be here.

jakemac53 added a commit that referenced this issue Jan 14, 2020
…async errors (#2599)

Fixes #2596

Specifically if the `action` callback throws any exceptions then we would leak those as unhandled async errors.

We can't await the call to `runBuilder` because that would block on the `tearDown` future which would hang tests.

The solution is to just swallow all errors from the unawaited future, and rely on the `onDone` Future to report most errors. We try/catch the action callback and forward the errors to the `onDone` completer.
kevmoo added a commit to kevmoo/source_gen_test that referenced this issue Jan 14, 2020
kevmoo added a commit to kevmoo/source_gen_test that referenced this issue Jan 14, 2020
@natebosch natebosch reopened this Feb 15, 2022
@natebosch
Copy link
Member

Reopening for more discussion. This change can cause some legitimate failures to get lost.

When I drop the .catchError here I can't repro any failure with the source_gen_test tests. @kevmoo - do you expect that something changed in those tests?

I'm not sure how much retaining these specific errors would help though. If the async error comes after the builder completes normally we'd still ignore those errors.

if (done.isCompleted) return;

@jakemac53
Copy link
Contributor

@natebosch should we close this at this point?

@natebosch
Copy link
Member

I think #3253 and #3245 are examples of things that we can miss because of this design.

I found both of those examples while I was experimenting with migrating those tests to package:checks.

I think this is still a likely issue when using expect, but with checks we'd more likely get an unawaited_future, and the await resolves the issue.

I think that the complexity to solve this is not justified for continued safety with a library that has a foot-gun around async expectations. If we invest in async safety for package:matcher I'd first look at adding lints to use expectLater with AsyncMatcher which I think also would add enough safety for this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:build_test type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants