Skip to content

Commit ca03588

Browse files
nateboschCommit Queue
authored andcommitted
Run extension handlers in the registering zone
Towards flutter/flutter#93676 Flutter uses an extension for hot reloads, and the app ends up running in the root zone after a hot reload because that is the zone that the handler gets called in. Always run extension handler callbacks in the zone from which they were registered for more predictable behavior. Change-Id: Ia921489a6ada802c8e53a0ccc650a8bce218ba01 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275842 Commit-Queue: Ben Konyi <[email protected]> Auto-Submit: Nate Bosch <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent d02e1de commit ca03588

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
- **Breaking change** [#49529][]:
6363
- Removed the deprecated [`MAX_USER_TAGS`][] constant.
6464
Use [`maxUserTags`][] instead.
65+
- Callbacks passed to `registerExtension` will be run in the zone from which
66+
they are registered.
6567

6668
[#49529]: https://github.com/dart-lang/sdk/issues/49529
6769
[`MAX_USER_TAGS`]: https://api.dart.dev/stable/dart-developer/UserTag/MAX_USER_TAGS-constant.html

‎sdk/lib/developer/extension.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ void registerExtension(String method, ServiceExtensionHandler handler) {
122122
}
123123
// TODO: When NNBD is complete, delete the following line.
124124
checkNotNullable(handler, 'handler');
125-
_registerExtension(method, handler);
125+
final zoneHandler = Zone.current.bindBinaryCallback(handler);
126+
_registerExtension(method, zoneHandler);
126127
}
127128

128129
/// Whether the "Extension" stream currently has at least one listener.

0 commit comments

Comments
 (0)