#167410: _initCalled completed twice
This PR Fixes: https://github.com/flutter/flutter/issues/167410, where _initCalled was being performed twice on the web
Based on the discussion comments I have removed the calles to _initCalled in the google_sign_in_web package
Pre-Review Checklist
- [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] I read the Tree Hygiene page, which explains my responsibilities.
- [x] I read and followed the relevant style guides and ran the auto-formatter.
- [x] I signed the CLA.
- [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g.
[shared_preferences] - [x] I linked to at least one issue that this PR fixes in the description above.
- [x] I updated
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under[^1]. - [x] I updated
CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under[^1]. - [x] I updated/added any relevant documentation (doc comments with
///). - [ ] I added new tests to check the change I am making, or I have commented below to indicate which test exemption this PR falls under[^1].
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.
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.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.
Hi,
any idea or pointers on how to fix this:
The following TestFailure was thrown running a test (but after
the test had completed):
Expected: throws <Instance of 'StateError'>
Actual: <Closure: () => Future<Null> from: () => {
let t$goto = 0, t$completer =
async._makeAsyncAwaitCompleter(T.Null());
var t$36asyncBody =
async._wrapJsFunctionForAsync((t$errorCode, t$result) => {
if (t$errorCode === 1) return
async._asyncRethrow(t$result, t$completer);
while (true)
switch (t$goto) {
case 0:
// Function start
t$goto = 2;
return
async._asyncAwait(t$36$35plugin$35get().disconnect(C[8] ||
CT.C8), t$36asyncBody, t$completer);
case 2:
// returning from await.
// implicit return
return
async._asyncReturn(null, t$completer);
}
});
return
async._asyncStartSync(t$36asyncBody, t$completer);
}>
Which: returned a Future that emitted <null>
When the exception was thrown, this was the stack:
its failing for the same reason in 3 of the tests and the repo check I know the issue which I will fix...
I'm not sure I understand the question. The expectations that check that calling a method without calling init throws a StateError are failing because you removed the code that throws the StateError if a method is called without calling init.
Oh so the changes in the PR is incorrect? Or something else needs to change?
Tests that expect that the web implementation asserts init completion everywhere are no longer valid if the web implementation no longer asserts init completion. Intentional behavioral changes often require changing tests.
Understood let me look at the code and see where the initCompleted is still be called in the test and remove those... Last I checked wasn't able to find any
From triage: Is this ready for review?
Yes its ready for review looks like I might need to fix the conflicts which I will get to
I made the changes based on what was put in the issue... What I got from it was since the logic has been moved outside the package the code for init seems redundant... I might have miss understood let me take a look based on the comments and try and incorporate it
@stuartmorgan-g what do other platforms do in this case?
Nothing; in the new version of google_sign_in, clients explicitly call an initialize method (rather than it being an internal, implicit thing on most platforms, but semi-exposed on web, as was the case before), and the docs say they must do so exactly once. It's a programming error by the client to write the code you've shown there.
If we think clients need explicit Errors when doing the wrong thing, that should be added to the app-facing package, rather than handled in each implementation. This code is a legacy of the exposed-for-web nature of the previous init code.
(Also, clients should basically never call the platform interface methods directly. That's not how most federated plugins are designed.)
Thank you, I will work on it with the directions provided and update the PR
Is it ok if I close this PR and open a new one?
@srivats22 What would the goal of doing that be? Making it harder to find all the review context makes continuing the review much harder.
@srivats22 What would the goal of doing that be? Making it harder to find all the review context makes continuing the review much harder.
Oh ok no worries I will just push to this... Was just thinking the number of commits were increasing hence...
From triage: @srivats22 Are you still planning on updating this PR based on the review feedback?
From triage: @srivats22 Are you still planning on updating this PR based on the review feedback?
Hi,
yes I am still working on it... I had posted a question: Quick question on this, should _isInitCalled be a local boolean? or how should I procceed on it? Once I get the answer I will try and finalize it by this week
I had posted a question: Quick question on this, should _isInitCalled be a local boolean?
I don't see anywhere in the discussion above where you asked that; the only comment since the last review was when you asked about creating a new PR.
You'll need to provide more context for the question, since I'm not sure what you mean. I don't see how a local variable would be relevant to the previous discussion.
I had posted a question: Quick question on this, should _isInitCalled be a local boolean?
I don't see anywhere in the discussion above where you asked that; the only comment since the last review was when you asked about creating a new PR.
You'll need to provide more context for the question, since I'm not sure what you mean. I don't see how a local variable would be relevant to the previous discussion.
Sorry I had accidently put it as a review comment have attached a screenshot of the same
@srivats22 yes _isInitCalled should be private and serve a single purpose: detect when init() is called more than once.
How do I fix the build failures?