Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [#988](https://github.com/mozilla/glean.js/pull/988): BUGFIX: Enforce rate limitation at upload time, not at ping submission time.
* Note: This change required a big refactoring of the internal uploading logic.
* [#1015](https://github.com/mozilla/glean.js/pull/1015): BUGFIX: Make attempting to call the `setUploadEnabled` API before initializing Glean a no-op.
* [#1016](https://github.com/mozilla/glean.js/pull/1016): BUGFIX: Make shutdown a no-op in case Glean is not initialized.

# v0.27.0 (2021-11-22)

Expand Down
7 changes: 7 additions & 0 deletions glean/src/core/glean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ class Glean {
* Finishes executing all pending tasks
* and shuts down both Glean's dispatcher and the ping uploader.
*
* If Glean is not initialized this is a no-op.
*
* # Important
*
* This is irreversible.
Expand All @@ -456,6 +458,11 @@ class Glean {
* @returns A promise which resolves once the shutdown is complete.
*/
static async shutdown(): Promise<void> {
if (!Context.initialized) {
log(LOG_TAG, "Attempted to shutdown Glean, but Glean is not initialized. Ignoring.");
return;
}

// Order here matters!
//
// The dispatcher needs to be shutdown first,
Expand Down
8 changes: 8 additions & 0 deletions glean/tests/unit/core/glean.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,14 @@ describe("Glean", function() {
assert.ok(postSpy.getCall(0).args[0].indexOf(DELETION_REQUEST_PING_NAME) !== -1);
});

it("attempting to shutdown Glean prior to initialize is a no-op", async function() {
await Glean.testUninitialize();

const launchSpy = sandbox.spy(Context.dispatcher, "launch");
await Glean.shutdown();
assert.strictEqual(launchSpy.callCount, 0);
});

it("events database is initialized at a time when metrics can already be recorded", async function() {
const event = new EventMetricType({
category: "test",
Expand Down