File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 66* [ #988 ] ( https://github.com/mozilla/glean.js/pull/988 ) : BUGFIX: Enforce rate limitation at upload time, not at ping submission time.
77 * Note: This change required a big refactoring of the internal uploading logic.
88* [ #1015 ] ( https://github.com/mozilla/glean.js/pull/1015 ) : BUGFIX: Make attempting to call the ` setUploadEnabled ` API before initializing Glean a no-op.
9+ * [ #1016 ] ( https://github.com/mozilla/glean.js/pull/1016 ) : BUGFIX: Make shutdown a no-op in case Glean is not initialized.
910
1011# v0.27.0 (2021-11-22)
1112
Original file line number Diff line number Diff line change @@ -448,6 +448,8 @@ class Glean {
448448 * Finishes executing all pending tasks
449449 * and shuts down both Glean's dispatcher and the ping uploader.
450450 *
451+ * If Glean is not initialized this is a no-op.
452+ *
451453 * # Important
452454 *
453455 * This is irreversible.
@@ -456,6 +458,11 @@ class Glean {
456458 * @returns A promise which resolves once the shutdown is complete.
457459 */
458460 static async shutdown ( ) : Promise < void > {
461+ if ( ! Context . initialized ) {
462+ log ( LOG_TAG , "Attempted to shutdown Glean, but Glean is not initialized. Ignoring." ) ;
463+ return ;
464+ }
465+
459466 // Order here matters!
460467 //
461468 // The dispatcher needs to be shutdown first,
Original file line number Diff line number Diff line change @@ -553,6 +553,14 @@ describe("Glean", function() {
553553 assert . ok ( postSpy . getCall ( 0 ) . args [ 0 ] . indexOf ( DELETION_REQUEST_PING_NAME ) !== - 1 ) ;
554554 } ) ;
555555
556+ it ( "attempting to shutdown Glean prior to initialize is a no-op" , async function ( ) {
557+ await Glean . testUninitialize ( ) ;
558+
559+ const launchSpy = sandbox . spy ( Context . dispatcher , "launch" ) ;
560+ await Glean . shutdown ( ) ;
561+ assert . strictEqual ( launchSpy . callCount , 0 ) ;
562+ } ) ;
563+
556564 it ( "events database is initialized at a time when metrics can already be recorded" , async function ( ) {
557565 const event = new EventMetricType ( {
558566 category : "test" ,
You can’t perform that action at this time.
0 commit comments