Skip to content

Commit 76a724d

Browse files
committed
Fix circular dependency between utils and context
I know the solution here is a bit sloppy, but I decided to pick my battles and got he easy route on this one.
1 parent 4cb6118 commit 76a724d

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

glean/src/core/context.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type PingsDatabase from "./pings/database.js";
99
import type ErrorManager from "./error/index.js";
1010
import Dispatcher from "./dispatcher.js";
1111
import log, { LoggingLevel } from "./log.js";
12-
import { isUndefined } from "./utils.js";
1312

1413
const LOG_TAG = "core.Context";
1514

@@ -31,7 +30,7 @@ export class Context {
3130
private _dispatcher: Dispatcher;
3231

3332
// The following group of properties are all set on Glean.initialize
34-
// Attempting to get them before initialize Glean will throw an error.
33+
// Attempting to get them before they are set will log an error.
3534
private _uploadEnabled!: boolean;
3635
private _metricsDatabase!: MetricsDatabase;
3736
private _eventsDatabase!: EventsDatabase;
@@ -64,9 +63,7 @@ export class Context {
6463
*
6564
* Resets the Context to an uninitialized state.
6665
*/
67-
static async testUninitialize(): Promise<void> {
68-
// Clear the dispatcher queue.
69-
await Context.instance._dispatcher?.testUninitialize();
66+
static testUninitialize(): void {
7067
Context._instance = undefined;
7168
}
7269

@@ -75,7 +72,7 @@ export class Context {
7572
}
7673

7774
static get uploadEnabled(): boolean {
78-
if (isUndefined(Context.instance._uploadEnabled)) {
75+
if (typeof Context.instance._uploadEnabled === "undefined") {
7976
log(
8077
LOG_TAG,
8178
[
@@ -93,7 +90,7 @@ export class Context {
9390
}
9491

9592
static get metricsDatabase(): MetricsDatabase {
96-
if (isUndefined(Context.instance._metricsDatabase)) {
93+
if (typeof Context.instance._metricsDatabase === "undefined") {
9794
log(
9895
LOG_TAG,
9996
[
@@ -111,7 +108,7 @@ export class Context {
111108
}
112109

113110
static get eventsDatabase(): EventsDatabase {
114-
if (isUndefined(Context.instance._eventsDatabase)) {
111+
if (typeof Context.instance._eventsDatabase === "undefined") {
115112
log(
116113
LOG_TAG,
117114
[
@@ -129,7 +126,7 @@ export class Context {
129126
}
130127

131128
static get pingsDatabase(): PingsDatabase {
132-
if (isUndefined(Context.instance._pingsDatabase)) {
129+
if (typeof Context.instance._pingsDatabase === "undefined") {
133130
log(
134131
LOG_TAG,
135132
[
@@ -147,7 +144,7 @@ export class Context {
147144
}
148145

149146
static get errorManager(): ErrorManager {
150-
if (isUndefined(Context.instance._errorManager)) {
147+
if (typeof Context.instance._errorManager === "undefined") {
151148
log(
152149
LOG_TAG,
153150
[
@@ -165,7 +162,7 @@ export class Context {
165162
}
166163

167164
static get applicationId(): string {
168-
if (isUndefined(Context.instance._applicationId)) {
165+
if (typeof Context.instance._applicationId === "undefined") {
169166
log(
170167
LOG_TAG,
171168
[
@@ -191,7 +188,7 @@ export class Context {
191188
}
192189

193190
static get debugOptions(): DebugOptions {
194-
if (isUndefined(Context.instance._debugOptions)) {
191+
if (typeof Context.instance._debugOptions === "undefined") {
195192
log(
196193
LOG_TAG,
197194
[

glean/src/core/glean.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ class Glean {
528528
}
529529

530530
// Get back to an uninitialized state.
531-
await Context.testUninitialize();
531+
Context.testUninitialize();
532532

533533
// Deregister all plugins
534534
testResetEvents();

glean/tests/unit/core/context.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ describe("Context", function() {
6969
assert.ok(Context.pingsDatabase instanceof PingsDatabase);
7070
});
7171

72-
it("the dispatcher is always available", async function () {
72+
it("the dispatcher is always available", function () {
7373
const originalDispatcher = Context.dispatcher;
7474
assert.notStrictEqual(originalDispatcher, null);
7575

76-
await Context.testUninitialize();
76+
Context.testUninitialize();
7777

7878
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
7979
// @ts-ignore

0 commit comments

Comments
 (0)