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
Fix hot restart flake #122776
Fix hot restart flake #122776
Conversation
…nt-on-failure-web-hotrestart-tests
…-hot-restart-flake
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. |
error is vm_service.RPCError && | ||
(error.code == RPCErrorCodes.kServiceDisappeared || | ||
error.code == RPCErrorCodes.kInternalError && | ||
error.message.contains('Sentinel kind: Collected'))) { |
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.
@bkonyi chrome proxy service throws a sentinel exception on getIsolate for non-existing isolate id, as required by the VmServiceInterface, but the VmServerConnection translates it into an RPC error with RPCError.kInternalError as code, and the sentinel is added to the message as a string, so I have to check for the string contents here. Is there a better way to handle this error? Should we change the VMServer connection to throw something different, or have a set of error codes in package:vm_service we all agree on and can check for here?
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.
service.getIsolate(...)
should be throwing a SentinelException
in this case, so there's likely something wrong with the encoding on the DWDS side of things. What's the JSON response you're seeing here? It should look something like:
{
"id": "123",
"result": {
"type": "Sentinel",
"kind": "Collected",
"valueAsString": "..."
}
}
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.
If I had to guess, the "error" property is being populated instead, which is incorrect.
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.
dwds's Chrome proxy service throws a sentinel exception, but the vm server connection we use on top of it converts it to RPC error with code of RPCError.kInternalError
here:
https://github.com/dart-lang/sdk/blob/67f3e1f4a0dfe57c07192607095892a9d107a9d1/pkg/vm_service/lib/src/vm_service.dart#L1795
Should this code be changed then?
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.
I will file an issue in the SDK repo for this, in the meanwhile the current PR should fix the flake.
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.
Filed an issue (i am worried about all the other cases where we miss error checks due to this problem): dart-lang/sdk#51752
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
Landing on red luci-flutter as this fixes one of the reasons the tree is currently red |
This reverts commit 62171df.
Wowowow, thanks for the fix! 🙏 |
Fixes latest flakes in web hot restart tests.
Details
I was able to add delays in various parts of the code to repro the flake pretty consistently - it was caused by a race between serving DevTools and hot restart with a following interleaving sequence of events:
flutter/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart
Line 593 in 961df98
FlutterVmService.findExtensionIsolate
flutter/packages/flutter_tools/lib/src/vmservice.dart
Line 1022 in 961df98
flutter/packages/flutter_tools/lib/src/vmservice.dart
Line 1025 in 961df98
The fix
Update the check to account for sentinel exceptions returned from
VmServerConnection
in https://github.com/dart-lang/sdk/blob/67f3e1f4a0dfe57c07192607095892a9d107a9d1/pkg/vm_service/lib/src/vm_service.dart#L1795Closes: #121708