Closed Bug 1222042 Opened 9 years ago Closed 9 years ago

TypeError: date is undefined when loading about:telemetry with Telemetry disabled

Categories

(Toolkit :: Telemetry, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: Margaret, Assigned: robertthyberg, Mentored)

References

Details

(Whiteboard: [measurement:client][lang=js][good next bug])

Attachments

(1 file, 3 obsolete files)

I noticed this with a local build while working on bug 1219240.

Here's the stack I saw in the console.

TypeError: date is undefined
this.TelemetryUtils.truncateToDays()
 TelemetryUtils.jsm:44
getMetadata()
 TelemetrySession.jsm:1037
getSessionPayload()
 TelemetrySession.jsm:1328
getPayload()
 TelemetrySession.jsm:1656
this.TelemetrySession<.getPayload()
 TelemetrySession.jsm:626
Impl.getCurrentPingData()
 TelemetryController.jsm:963
this.TelemetryController<.getCurrentPingData()
 TelemetryController.jsm:239
PingPicker._updateCurrentPingData()
 aboutTelemetry.js:327
PingPicker.update()
 aboutTelemetry.js:317
onLoad/<()
 aboutTelemetry.js:1463
onLoad()
TelemetrySession._sessionStartDate is undefined. Which is odd, because (near as I can tell) it should be set to _subsessionStartDate which is set to Policy.now().

Did you override Policy.now for your testing? If not, it should've just been `new Date()`
Flags: needinfo?(margaret.leibovic)
I think i've seen that come up before in local builds where Telemetry is not enabled, it is probably limited to that scenario.
(Longer-term i'd love to avoid those kind of issues by basically always having Telemetry recording enabled, but Telemetry upload disabled unless overridden for local builds).
(In reply to Chris H-C :chutten from comment #1)
> TelemetrySession._sessionStartDate is undefined. Which is odd, because (near
> as I can tell) it should be set to _subsessionStartDate which is set to
> Policy.now().
> 
> Did you override Policy.now for your testing? If not, it should've just been
> `new Date()`

No, I didn't do anything in my testing, other than create a new histogram. This was with a fresh install, so could it be some bug where the session wasn't started immediately?

I can't reproduce now... maybe we should close this bug out, unless I can find a way for this to happen again.

(In reply to Georg Fritzsche [:gfritzsche] from comment #2)
> I think i've seen that come up before in local builds where Telemetry is not
> enabled, it is probably limited to that scenario.
> (Longer-term i'd love to avoid those kind of issues by basically always
> having Telemetry recording enabled, but Telemetry upload disabled unless
> overridden for local builds).

Always recording telemetry makes sense to me! It's even necessary for testing new probes in local builds.
Flags: needinfo?(margaret.leibovic)
> (In reply to Georg Fritzsche [:gfritzsche] from comment #2)
> > I think i've seen that come up before in local builds where Telemetry is not
> > enabled, it is probably limited to that scenario.
> > (Longer-term i'd love to avoid those kind of issues by basically always
> > having Telemetry recording enabled, but Telemetry upload disabled unless
> > overridden for local builds).
> 
> Always recording telemetry makes sense to me! It's even necessary for
> testing new probes in local builds.

Yes, i think the setup is pretty confusing for developers right now (plus we don't really gain anything from having recording off).
Bug 1200164 should resolve this issue by cleaning this up.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
Let's reopen this, since Nick has also seen this. Until the error is fixed (whether that's by bug 1200164 or not), this isn't resolved.
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
OS: Android → All
Priority: -- → P3
Summary: TypeError: date is undefined when loading about:telemetry on Android → TypeError: date is undefined when loading about:telemetry with Telemetry disabled
Whiteboard: [measurement:client]
To fix this, we should:

- Return null from TelemetryController.getCurrentPingData in [0] if Telemetry.canRecordBase is false.
- Change the function comments to mention the return value is either the ping data or null
- Return in [1] if ping is null.

To check if this works:

- ./mach xpcshell-test toolkit/components/telemetry
- Manually check that there's no error in the browser console when opening about:telemetry with FHR+Telemetry off and on

[0] - https://dxr.mozilla.org/mozilla-central/rev/cc473fe5dc512c450634506f68cbacfb40a06a23/toolkit/components/telemetry/TelemetryController.jsm#961
[1] - https://dxr.mozilla.org/mozilla-central/rev/cc473fe5dc512c450634506f68cbacfb40a06a23/toolkit/content/aboutTelemetry.js#327
Mentor: alessio.placitelli, gfritzsche
Whiteboard: [measurement:client] → [measurement:client][lang=js][good next bug]
Robert, are you interested in taking this one?
Flags: needinfo?(robertthyberg)
yes!
Flags: needinfo?(robertthyberg)
Attached patch bug-1222042 (obsolete) — Splinter Review
Attachment #8686296 - Flags: review?(alessio.placitelli)
Assignee: nobody → robertthyberg
Comment on attachment 8686296 [details] [diff] [review]
bug-1222042

Review of attachment 8686296 [details] [diff] [review]:
-----------------------------------------------------------------

Thank you for the patch, we're almost there! ;)

Could you change the commit message to something like: "Bug 1222042 - Don't try to display ping data in about:telemetry when Telemetry is disabled"

::: toolkit/components/telemetry/TelemetryController.jsm
@@ +956,5 @@
>    },
>  
> +  /**
> +   * Gets current ping data
> +   * @return {ping} returns ping data if Telemetry.canRecordBase is true

Don't add this comment here, instead, change the one at: https://dxr.mozilla.org/mozilla-central/rev/84a7cf29f4f14c9b359db2f7f19c0abd6a8e178e/toolkit/components/telemetry/TelemetryController.jsm#238

Maybe to something like "@return {Object} the ping data if Telemetry is enabled, null otherwise"

@@ +963,3 @@
>    getCurrentPingData: function(aSubsession) {
>      this._log.trace("getCurrentPingData - subsession: " + aSubsession)
>  

We don't need to gather the ping data if Telemetry is disabled, as it would return broken data. We should move the check here.

@@ +968,5 @@
>      const payload = TelemetrySession.getPayload(reason);
>      const options = { addClientId: true, addEnvironment: true };
>      const ping = this.assemblePing(type, payload, options);
>  
> +    if (!Telemetry.canRecordBase) {

Move this to the previous comment.

Nit: could you also add an inline comment about why we're bailing out? e.g. "// Telemetry is disabled, don't gather any data."
Attachment #8686296 - Flags: review?(alessio.placitelli) → feedback+
Attached patch bug-1222042 (obsolete) — Splinter Review
Attachment #8686296 - Attachment is obsolete: true
Attachment #8686811 - Flags: review?(alessio.placitelli)
Comment on attachment 8686811 [details] [diff] [review]
bug-1222042

Review of attachment 8686811 [details] [diff] [review]:
-----------------------------------------------------------------

Could you address the nit below and change the comment to something like: "Bug 1222042 - Don't try to show ping data in about:telemetry if Telemetry is disabled"?

::: toolkit/components/telemetry/TelemetryController.jsm
@@ +957,5 @@
>  
>    getCurrentPingData: function(aSubsession) {
>      this._log.trace("getCurrentPingData - subsession: " + aSubsession)
>  
> +    //Telemetry is disabled, don't gather any data.

Nit: Could you add a whitespace before "Telemetry"?
Attachment #8686811 - Flags: review?(alessio.placitelli) → feedback+
Attached patch bug-1222042 (obsolete) — Splinter Review
Attachment #8686811 - Attachment is obsolete: true
Attachment #8687836 - Flags: review?(alessio.placitelli)
Comment on attachment 8687836 [details] [diff] [review]
bug-1222042

Review of attachment 8687836 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good for me, thank you rthyberg!
Georg, do you have any other suggestion?
Attachment #8687836 - Flags: review?(alessio.placitelli)
Attachment #8687836 - Flags: review+
Attachment #8687836 - Flags: feedback?(gfritzsche)
Comment on attachment 8687836 [details] [diff] [review]
bug-1222042

Review of attachment 8687836 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks, this looks good to me, only one small nit below.

::: toolkit/components/telemetry/TelemetryController.jsm
@@ +960,5 @@
>  
> +    // Telemetry is disabled, don't gather any data.
> +    if (!Telemetry.canRecordBase) {
> +      return null;
> +    }

Nit: Add an empty line after this to help with readability.
Attachment #8687836 - Flags: feedback?(gfritzsche) → feedback+
Attached patch bug-1222042Splinter Review
Attachment #8687836 - Attachment is obsolete: true
Attachment #8688118 - Flags: checkin?
Attachment #8688118 - Flags: checkin?
Comment on attachment 8688118 [details] [diff] [review]
bug-1222042

Robert, can you push this to try to make sure it's ok?
Attachment #8688118 - Flags: review+
https://hg.mozilla.org/integration/fx-team/rev/2bd33b89c477e60aa80624a5edaa3bb74cbfe2df
Bug 1222042 - Dont try to show ping data in about:telemetry if Telemetry is disabled. r=dexter
Status: REOPENED → ASSIGNED
https://hg.mozilla.org/mozilla-central/rev/2bd33b89c477
Status: ASSIGNED → RESOLVED
Closed: 9 years ago9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: