-
Notifications
You must be signed in to change notification settings - Fork 29.1k
CrashReportSender dependency injection #54924
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
Conversation
\cc @jamesderlin |
overrides: <Type, Generator>{ | ||
FileSystem: () => MemoryFileSystem(), |
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 know the double override is kind of weird, but I couldn't think of another way to do this so:
- With a real crash, it always uses LocalFileSystem regardless of context (see previous note about recording):
/// File system used by the crash reporting logic.
///
/// We do not want to use the file system stored in the context because it may
/// be recording. Additionally, in the case of a crash we do not trust the
/// integrity of the [AppContext].
- Still lets the test inject a MemoryFileSystem.
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.
We don't support recording anymore. The latter part about not trusting AppContext is a bit suspect, I don't really think we've had any issues for the last few years regarding AppContext
} | ||
} | ||
} | ||
|
||
/// [fs] is injected into this method instead of the constructor |
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.
Its a bit confusing that some of the dependencies are constructor injected and some are passed here. GitHubTemplateCreator would be more obviously optional if it were constructor injected, right?
If the goal is only for internal users to see non-github error messages, then why does the whole |
In google3 we'd also like to override |
Currently, the scope of |
I'd like to rename |
This sounds more promising. I expect this approach to be able to avoid the layering violation, and avoid exposing more interfaces to g3 than necessary to solve the current issue.
Both external and g3 currently send crashes to the same place. I would personally advocate against doing otherwise since it would make crash triage more difficult. |
I reduced the scope of this PR. It no longer moves anything into the context, it just changes the way dependencies are injected into |
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.
LGTM!
(But not to CI) |
Remove
CrashReportSender.initializeWith
in favor of dependency injection into theCrashReportSender
constructor.Remove
tool.crashFileSystem
in favor of the context file system.Related Issues
#54886
#53766
#47161
Tests
Rewrote most of
crash_reporting_test
.Checklist
///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change