-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Conversation
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. |
test-exempt: code refactor with no semantic change |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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
_getNewServiceWorker(reg) { | |
_getNewServiceWorker(serviceWorkerRegistration) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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 :)
packages/flutter_tools/lib/src/web/file_generators/js/flutter.js
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/web/file_generators/js/flutter.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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!
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; | ||
} |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@p-mazhnik this is independent of #130206. How about we get this one landed, and then have 130206 updated on top of this change? |
@ditman sounds good, let's do this way! |
OK @p-mazhnik this has immediately landed, you should be able of rebasing #130206 whenever it's convenient to you! |
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); ```
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:
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.