Skip to content

Commit 20f2cbf

Browse files
authored
fix(core, web): skip hot-restart listener cleanup in profile mode (#18729)
Profile builds left dart.vm.product unset, so web listeners were stored under the shared 'no-op' key and the next subscription cancelled them.
1 parent ef07ae2 commit 20f2cbf

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

  • packages/firebase_core/firebase_core_web/lib/src/interop/utils

‎packages/firebase_core/firebase_core_web/lib/src/interop/utils/utils.dart‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@ import 'package:web/web.dart' as web;
1414

1515
import 'func.dart';
1616

17+
// Hot restart exists only in debug mode. This must match Flutter's
18+
// kDebugMode (`!dart.vm.product && !dart.vm.profile`). Profile builds leave
19+
// dart.vm.product false, so gating on product mode alone still stores JS
20+
// unsubscribe functions on window. Plugins then share the key 'no-op'
21+
// outside debug and cancel the previous listener on the next subscription.
22+
// See https://github.com/firebase/flutterfire/issues/18728.
1723
// ignore: do_not_use_environment
18-
const bool _kDebugMode = !bool.fromEnvironment('dart.vm.product');
24+
const bool _kReleaseMode = bool.fromEnvironment('dart.vm.product');
25+
26+
// ignore: do_not_use_environment
27+
const bool _kProfileMode = bool.fromEnvironment('dart.vm.profile');
28+
29+
const bool _kDebugMode = !_kReleaseMode && !_kProfileMode;
1930

2031
/// Handles the [Future] object with the provided [mapper] function.
2132
JSPromise handleFutureWithMapper<T, S>(

0 commit comments

Comments
 (0)