Closed Bug 1738118 Opened 4 years ago Closed 4 years ago

Unexpected behavior when Glean initialized with uploadEnabled `false`

Categories

(Data Platform and Tools Graveyard :: Glean.js, defect, P1)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: sarah, Assigned: brizental)

References

Details

Attachments

(1 file)

Platform: Qt
Glean version: 0.23
Integration: MozillaVPN

Here's the relevant chunk of code: https://github.com/mozilla-mobile/mozilla-vpn-client/blob/main/src/ui/main.qml#L291-L319

When we initialize with uploadEnabled true, everything is fine.

When we initialize glean with uploadEnabled false, we are seeing odd behavior. If a user has opted out of data collection, then VPNSettings.gleanEnabled is false. We still initialize glean on startup, but with the uploadEnabled parameter set to false.

A few seconds after initialization we start calling Pings.main.submit(); on a timer.

This is what we see in our VPN logs (edited to just glean logging):

[27.10.2021 16:21:02.809] Debug: (main - MozillaVPN) Initializing Glean                                                                                                                       
[27.10.2021 16:21:02.809] Debug: Initializing glean with debug mode (main.qml:294, onInitializeGlean)                                                                                         
[27.10.2021 16:21:02.809] Debug: Initializing glean with channel set to: staging . uploadEnabled set to: false (main.qml:301, onInitializeGlean)                                              
[27.10.2021 16:21:02.848] Error: (Glean.core.Context) Attempted to access Context.uploadEnabled before it was set. This may cause unexpected behaviour. (glean.lib.js:1, a)
[27.10.2021 16:21:02.848] Error: (Glean.core.Context) Attempted to access Context.uploadEnabled before it was set. This may cause unexpected behaviour. (glean.lib.js:1, a)
[27.10.2021 16:21:06.967] Debug: sending Glean pings (main.qml:317, onSendGleanPings)
[27.10.2021 16:21:06.967] Error: (Glean.core.Context) Attempted to access Context.uploadEnabled before it was set. This may cause unexpected behaviour. (glean.lib.js:1, a)
[27.10.2021 16:21:06.968] Info: (Glean.core.Pings.PingType) Glean disabled: not submitting pings. Glean may still submit the deletion-request ping. (glean.lib.js:1, a)

We will then see the last lines repeated every time our timer hits to send pings.

[27.10.2021 16:21:06.967] Debug: sending Glean pings (main.qml:317, onSendGleanPings)
[27.10.2021 16:21:06.967] Error: (Glean.core.Context) Attempted to access Context.uploadEnabled before it was set. This may cause unexpected behaviour. (glean.lib.js:1, a)
[27.10.2021 16:21:06.968] Info: (Glean.core.Pings.PingType) Glean disabled: not submitting pings. Glean may still submit the deletion-request ping. (glean.lib.js:1, a)

I'm aware that the error isn't harmful (although I would argue that it would probably be better as a warning), but the Errors are unexpected none-the-less (and they are causing confusion among other devs).

Assignee: nobody → brizental
Priority: P4 → P1
Whiteboard: [telemetry:glean-js:m?]

[27.10.2021 16:21:02.848] Error: (Glean.core.Context) Attempted to access Context.uploadEnabled before it was set. This may cause unexpected behaviour. (glean.lib.js:1, a)

Hm, this log message should only show up if uploadEnabled is undefined (see: https://github.com/mozilla/glean.js/blob/main/glean/src/core/context.ts#L77). I can't reproduce the issue when passing a false value to Glean.initialize on our Qt sample app.

Would you kindly check if the value for VPNSettings.gleanEnabled is false or undefined?

I'm aware that the error isn't harmful (although I would argue that it would probably be better as a warning), but the Errors are unexpected none-the-less (and they are causing confusion among other devs).

I disagree on making this a warning, because in other situations it could cause undefined behaviour. It's a bad error message though, so I will rephrase it to make it more actionable.

See Also: → 1738208
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Product: Data Platform and Tools → Data Platform and Tools Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: