Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web] remove unnecessary awaits from flutter.js #130204

Merged
merged 6 commits into from
Jul 14, 2023

Conversation

p-mazhnik
Copy link
Contributor

@p-mazhnik p-mazhnik commented Jul 8, 2023

Fixed types for _getNewServiceWorker and _waitForServiceWorkerActivation functions.
These functions currently expect a Promise as an argument, but we're actually passing in an already resolved value:

.then(this._getNewServiceWorker)
.then(this._waitForServiceWorkerActivation);

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 8, 2023
@Hixie
Copy link
Contributor

Hixie commented Jul 8, 2023

test-exempt: code refactor with no semantic change

Copy link
Member

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me. @ditman can you think of a good way to test this? NVM, this already has a test exemption.

async _getNewServiceWorker(serviceWorkerRegistrationPromise) {
const reg = await serviceWorkerRegistrationPromise;

_getNewServiceWorker(reg) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you substitute a more descriptive name

Suggested change
_getNewServiceWorker(reg) {
_getNewServiceWorker(serviceWorkerRegistration) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just didn't want to rename existing usages of the reg variable below

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do

Copy link
Contributor Author

@p-mazhnik p-mazhnik Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I also rename serviceWorker to the latestServiceWorker in _waitForServiceWorkerActivation function?
I don't like that this function currently (in my PR) has meaningless const serviceWorker = latestServiceWorker; line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or it can be the other way, latestServiceWorker -> serviceWorker

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, we don't need that extra assignment now that we don't have an await.

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fine-tuning this! However this will conflict with your other PR where you fix the global serviceWorkerVersion variable :)

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the cleanup!

Comment on lines 194 to 199
if (!serviceWorker) {
return Promise.reject(
new Error("Cannot activate a null service worker!")
);
throw new Error("Cannot activate a null service worker!");
} else {
console.debug("Service worker already active.");
return Promise.resolve();
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, much better! Thanks!

Copy link
Member

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@p-mazhnik
Copy link
Contributor Author

p-mazhnik commented Jul 14, 2023

Blocked by #130206

@christopherfujino christopherfujino added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Jul 14, 2023
@ditman
Copy link
Member

ditman commented Jul 14, 2023

@p-mazhnik this is independent of #130206. How about we get this one landed, and then have 130206 updated on top of this change?

@p-mazhnik
Copy link
Contributor Author

@ditman sounds good, let's do this way!

@ditman ditman added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 14, 2023
@auto-submit auto-submit bot merged commit 1c1c273 into flutter:master Jul 14, 2023
124 checks passed
@ditman
Copy link
Member

ditman commented Jul 14, 2023

OK @p-mazhnik this has immediately landed, you should be able of rebasing #130206 whenever it's convenient to you!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 18, 2023
@p-mazhnik p-mazhnik deleted the web-flutterjs-types branch July 27, 2023 13:12
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Jul 31, 2023
Fixed types for `_getNewServiceWorker` and `_waitForServiceWorkerActivation` functions.  
These functions currently expect a Promise as an argument, but we're actually passing in an already resolved value:
```js
.then(this._getNewServiceWorker)
.then(this._waitForServiceWorkerActivation);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants