-
Notifications
You must be signed in to change notification settings - Fork 34
Bug 1705720 - Ensure the dispatcher is always available #254
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
brizental
left a comment
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.
Would you mind also adding a simple test to ensure this behaviour?
| private static _instance: Context; | ||
|
|
||
| private _dispatcher!: Dispatcher; | ||
| private _dispatcher!: Dispatcher | null; |
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.
Why does this need to be null? Can't we initialize the dispatcher on the Context's 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.
This needs to be null because we can't really tear down the whole Context when we reset Glean, because we need to retain the storage. So we do a "soft reset" by nulling out the dispatcher in testReset
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.
nit: I would prefer private _dispatcher?: Dispatcher;, but no strong requirement for this change.
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.
That makes it undefined though,
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.
Yes, but this a very philosophical thing (null vs undefined) and makes no real difference here. Feel free to ignore the request ;)
Now that we're properly resetting, all the tests fail without the fix (instantiating the dispatcher if not available). Any test I might add would basically be the same, but let me see what I can pull off |
This guarantees the dispatcher is always available even before the Glean initialization. We need this because our APIs can be used before initialization, to perform fast recording of metrics.
d393a48 to
8c09ec7
Compare
This guarantees the dispatcher is always available even before the Glean initialization. We need this because our APIs can be used before initialization, to perform fast recording of metrics.