Closed Bug 1344737 Opened 9 years ago Closed 9 years ago

Update TelemetrySession.jsm to async function & await

Categories

(Toolkit :: Telemetry, enhancement, P4)

enhancement

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: gfritzsche, Assigned: djmdeveloper060796, Mentored)

References

Details

(Whiteboard: [measurement:client] [lang=js])

Attachments

(1 file)

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 replace: - `Task.async(function*(...))`, `Task.spawn(function*(...))` with a form of `async function ...` - `yield` with `await` in the changed functions https://dxr.mozilla.org/mozilla-central/search?q=path%3ATelemetrySession.jsm+Task.+yield&redirect=false The only case i can think of that doesn't migrate trivially is any `DeferredTask` usage, we could just leave those for now.
@Georg I would like to work on this. I've read the code and doc of async function. Can you let me know how to proceed further?
Attached patch bug1344737.patchSplinter Review
Updated TelemetrySession.jsm to async and await.
Attachment #8846390 - Flags: review?(gfritzsche)
Assignee: nobody → djmdeveloper060796
Comment on attachment 8846390 [details] [diff] [review] bug1344737.patch I'm short on time, redirecting request.
Attachment #8846390 - Flags: review?(gfritzsche) → review?(alessio.placitelli)
Chris, would you mind reviewing this bug?
Flags: needinfo?(chutten)
Flags: needinfo?(chutten)
Attachment #8846390 - Flags: review?(alessio.placitelli) → review?(chutten)
Comment on attachment 8846390 [details] [diff] [review] bug1344737.patch Review of attachment 8846390 [details] [diff] [review]: ----------------------------------------------------------------- Thank you for your patch! Have you run the telemetry tests with this patch? From your mozilla-central root, run mach test toolkit/components/telemetry/tests/unit/. It appears as though you may have changed all of the `yield` to `await` where you instead should have only changed the ones next to functions that you changed from `Task.*` to `async function`. ::: toolkit/components/telemetry/TelemetrySession.jsm @@ +1532,3 @@ > // Update the session data to keep track of new subsessions created before > // the initialization. > + await TelemetryStorage.saveSessionData(this._getSessionDataObject()); If the TelemetryStorage function has not been updated to async, this won't play nicely, I don't think. Best to leave this untouched and let bug 1344743 take care of making this change. @@ +1543,4 @@ > Telemetry.asyncFetchTelemetryData(function() {}); > > // Update the crash annotation with the proper client ID. > + annotateCrashReport(this._sessionId, await ClientID.getClientID(), If ClientID hasn't been updated to async function, then await won't work. @@ +2044,4 @@ > * @return {Promise<object>} A promise which is resolved with an object when > * loading has completed, with null otherwise. > */ > + async _loadSessionData() { Is this valid syntax?
Attachment #8846390 - Flags: review?(chutten)
@Chris I have run unit tests from mozilla-central root, all the tests are passing I had to use short hand notation for async function as otherwise I was getting esling error : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions#Shorthand_async_methods
Flags: needinfo?(chutten)
Interesting. I wonder if it all works because of the format of the Promises returned by those embedded functions. Let me throw this up on try (our build+test farm) and see if it can find any holes in it. Clearly I need more experience with these new asynchronous features :S The try build will progress here: https://treeherder.mozilla.org/#/jobs?repo=try&revision=7d73689619fa643de119775d06f91d92ac429b49 If it can't find anything, then it'll be an r+ and a checkin-needed from me.
Flags: needinfo?(chutten)
Comment on attachment 8846390 [details] [diff] [review] bug1344737.patch Review of attachment 8846390 [details] [diff] [review]: ----------------------------------------------------------------- try's green, and I have some reading to do so I can learn why :S
Attachment #8846390 - Flags: review+
Thank you very much!
Keywords: checkin-needed
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/d762468d4657 Update TelemetrySession.jsm to async function & await. r=chutten
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: