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

Improve FluxUiComponent disposed store logging #703

Merged
merged 6 commits into from
Aug 31, 2021
Merged

Conversation

greglittlefield-wf
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf commented Aug 27, 2021

Motivation

We have some warning logs in place for before FluxUiComponent(2) components attempt to subscribe to disposed stores.

These logs weren't very helpful, though, since they didn't contain a stack trace, component name, or store name.

Changes

  • Add more information to logs
    • Add a utility to get a Dart component name from its Dart instance
  • Add basic unit tests for this logging

Release Notes

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Client Platform member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

@aviary-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

/// List of store subscriptions created when the component mounts.
///
/// These subscriptions are canceled when the component is unmounted.
List<StreamSubscription> _subscriptions = [];

void _validateStoreDisposalState(Store store) {
String message = 'Cannot listen to a disposed/disposing Store.';
if (store.isOrWillBeDisposed) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrapped both the assert and the log in this check so we could conditionally build a shared message instead of computing it unnecessarily. The control-flow of this method should be the same as it was before.

@greglittlefield-wf greglittlefield-wf marked this pull request as ready for review August 30, 2021 16:37

var isDisposedOrDisposing = store.isOrWillBeDisposed ?? false;
final message = 'Cannot listen to a disposed/disposing Store.'
' (storeNameOrType: $storeNameOrType, shouldBatchRedraw: $shouldBatchRedraw)';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to use a ContextualMessage and put storeNameOrType and shouldBatchRedraw in the context of the message instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really wanted to do that, but unfortunately I'd have to depend on app_intelligence_dart to get that class (which we can't do since this is an OSS repo, but even if it weren't I'd be wary about).

It'd be nice if you could pass in a Map or some other core type and have it treat it the same as a ContextualMessage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh. I didn't realize that was an AID-specific class.

@todbachman-wf
Copy link
Member

QA +1. The unit tests added should be sufficient for this change.

@greglittlefield-wf
Copy link
Contributor Author

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from RM

@rmconsole6-wk rmconsole6-wk merged commit caa2e59 into master Aug 31, 2021
@rmconsole6-wk rmconsole6-wk deleted the improve-logging branch August 31, 2021 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants