-
Notifications
You must be signed in to change notification settings - Fork 58
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
HY-4957 Alert devs about batchedRedraw race condition, and log if it happens in prod. ⚠️ #72
Changes from 1 commit
a5d1b90
05bbe8c
7afb657
6a4041b
cad8b21
1c5f5a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,18 @@ void main() { | |
reason: 'component should no longer be listening after unmount'); | ||
}); | ||
|
||
test('does not subscribe to a store that is disposed or disposing', () async { | ||
var store = new TestStore(); | ||
var renderedInstance = render(TestDefault()..store = store); | ||
TestDefaultComponent component = getDartComponent(renderedInstance); | ||
expect(component.subscriptions.length, 1); | ||
|
||
await store.dispose(); | ||
renderedInstance = render(TestDefault()..store = store); | ||
component = getDartComponent(renderedInstance); | ||
expect(component.subscriptions.length, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively (or supplementarily), this could test that rendering does not cause an exception (when the store is listened to while disposing). Technically, that tests the failure case that we're addressing, but it also asserts the expected behavior in a weird way that is dependent on behavior from another repo. But it also wouldn't require the subscriptions list to be exposed. 🤷♂️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point; that could be done like so: test('does not subscribe to a store that is disposed or disposing', () async {
await store.dispose();
expect(() {
render(TestDefault()..store = store);
}, returnsNormally);
}); |
||
}); | ||
|
||
test('subscribes to any stores returned in redrawOn', () async { | ||
var stores = new TestStores(); | ||
var renderedInstance = render(TestRedrawOn()..store = stores); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to better ways to check the subscriptions in unit tests.