Closed
Bug 1329116
Opened 7 years ago
Closed 7 years ago
Update TelemetryEnvironment.jsm to async function & await
Categories
(Toolkit :: Telemetry, defect, P4)
Toolkit
Telemetry
Tracking
()
RESOLVED
FIXED
mozilla55
Tracking | Status | |
---|---|---|
firefox55 | --- | fixed |
People
(Reporter: gfritzsche, Assigned: djmdeveloper060796, Mentored)
References
Details
(Whiteboard: [measurement:client] [lang=js])
Attachments
(1 file, 4 obsolete files)
5.30 KB,
patch
|
gfritzsche
:
review+
|
Details | Diff | Splinter Review |
We have `async function` and `await` now: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function We should be able to switch all of the `Task.async`, `Task.spawn` and `function*` uses over to those: https://dxr.mozilla.org/mozilla-central/search?q=path%3Atoolkit%2Fcomponents%2Ftelemetry%2F+ext%3Ajs+ext%3Ajsm+Task.&redirect=false The only case i can think of that doesn't migrate trivially is the `DeferredTask` usage, we could just leave that one for now.
Reporter | ||
Comment 1•7 years ago
|
||
I would be happy to mentor this. Note though that this isn't a good first bug. Changes can be checked against our unit tests using: mach xpcshell-test toolkit/components/telemetry/tests/unit To start with a smaller change, you can make changes to e.g. only TelemetryEnvironment.jsm and run only the test for that: mach xpcshell-test toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.jsm After the tests runs through fine, we also need to manually test by running the Firefox build: - check that pings are still generated as expected on e.g. addon installs, using about:telemetry - sent out successfully, using https://github.com/mozilla/gzipServer - no new errors related to our code should show up in the browser console
Mentor: alessio.placitelli, gfritzsche
Whiteboard: [measurement:client] → [measurement:client] [lang=js]
Comment 2•7 years ago
|
||
Hi Georg! I have taken up a few good first bugs till now. I would like to take this up. Can you please assign it to me and help me get started with this?
Flags: needinfo?(gfritzsche)
Reporter | ||
Comment 3•7 years ago
|
||
Sure - the relevant information is in comment 0 & comment 1. We want to get rid of the mentioned `Task.*` and `function*` uses and instead use `async` & `await` instead. As mentioned, i really recommend starting with only the TelemetryEnvironment files to see how it works. Let us know if you run into any problems or have questions.
Flags: needinfo?(gfritzsche)
Assignee | ||
Comment 4•7 years ago
|
||
I am trying to solve this issue. I have started with the TelemetryEnvironment.jsm file. I am facing some problems. I have changed Task.async(function*() { /*stuff*/ }) to async function() { /*stuff*/ } however I am getting the following error (below attached file)
Assignee | ||
Comment 5•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Flags: needinfo?(gfritzsche)
Reporter | ||
Comment 6•7 years ago
|
||
The actual error line is:
> ERROR SyntaxError: yield is a reserved identifier at resource://gre/modules/TelemetryEnvironment.jsm:530
This is because `yield` is only allowed in generator functions [1], which were used with Task.async() etc. to wait on promises.
With the change you did, you need to use `await` instead of `yield`.
Flags: needinfo?(gfritzsche)
Reporter | ||
Comment 7•7 years ago
|
||
To reduce the scope of this bug, i'm limiting this to only changing TelemetryEnvironment.jsm.
Summary: Update Telemetry JS modules to async function & await → Update Telemetry environment module to async function & await
Reporter | ||
Updated•7 years ago
|
Summary: Update Telemetry environment module to async function & await → Update TelemetryEnvironment.jsm to async function & await
Reporter | ||
Updated•7 years ago
|
Assignee: nobody → djmdeveloper060796
Assignee | ||
Comment 8•7 years ago
|
||
I have changed yield to await, now there is no more errors
Attachment #8843683 -
Attachment is obsolete: true
Attachment #8843687 -
Attachment is obsolete: true
Attachment #8844321 -
Flags: review?(gfritzsche)
Reporter | ||
Comment 9•7 years ago
|
||
Comment on attachment 8844321 [details] [diff] [review] bug1329116.patch Review of attachment 8844321 [details] [diff] [review]: ----------------------------------------------------------------- Thanks! This looks good, with the eslint error below fixed. Lets also remove the import for Task.jsm at the start of the file. With the changes here it is no longer needed. ::: toolkit/components/telemetry/TelemetryEnvironment.jsm @@ +516,4 @@ > * changed - Whether the environment changed. > * oldEnvironment - Only set if a change occured, contains the environment data before the change. > */ > + _updateAddons: async function() { Please make sure to fix the eslint errors, e.g. from running: ./mach eslint toolkit/components/telemetry/ This can now use the shorthand async method definitions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions#Shorthand_async_methods
Attachment #8844321 -
Flags: review?(gfritzsche) → feedback+
Assignee | ||
Comment 10•7 years ago
|
||
Removed the eslint error
Attachment #8844321 -
Attachment is obsolete: true
Attachment #8844942 -
Flags: review?(gfritzsche)
Assignee | ||
Comment 11•7 years ago
|
||
fixed eslint errors and removed the import statement for Task.jsm
Attachment #8844942 -
Attachment is obsolete: true
Attachment #8844942 -
Flags: review?(gfritzsche)
Attachment #8844994 -
Flags: review?(gfritzsche)
Reporter | ||
Comment 12•7 years ago
|
||
Comment on attachment 8844994 [details] [diff] [review] bug1329116.patch Review of attachment 8844994 [details] [diff] [review]: ----------------------------------------------------------------- Thanks, this looks good!
Attachment #8844994 -
Flags: review?(gfritzsche) → review+
Reporter | ||
Comment 13•7 years ago
|
||
I've run the tests locally, this should be good to land.
Keywords: checkin-needed
Comment 14•7 years ago
|
||
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/4c2eaf534ed7 Update TelemetryEnvironment.jsm to async function & await. r=gfritzsche
Keywords: checkin-needed
Comment 15•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/4c2eaf534ed7
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox55:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Updated•7 years ago
|
status-firefox53:
affected → ---
You need to log in
before you can comment on or make changes to this bug.
Description
•