Repository: flutter
Issue: [go_router] Infinite redirect loops causing stack overflows
Labels: c: crash,platform-web,package,a: production,P2,needs repro info,p: go_router,team-go_router,triaged-go_router

On our production Flutter Web app using go_router 6.0.1 and Flutter 3.3.10, we're periodically seeing a redirect loop/stack overflow issue that _may_ be caused by certain browser extensions. This did not happen using go_router <5.0 and Flutter <3.3. This has been seen on Chrome, Edge and Safari.

Sentry reports look like the below. Judging from customer interactions and having them try different browsers and incognito mode, and both of those working, we'd estimate it might be due to certain browser extensions. We've been unable to identify the culprit ourselves, but there's definitely some weird edge case going on here.

```
minified:Ul: Stack Overflow
  at J.asi(org-dartlang-sdk:///lib/_internal/js_runtime/lib/interceptors.dart:155:17)
  at dartProgram(main.dart:258:3)
  at A.b_v.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.2.4/lib/src/interop/auth.dart:69:30)
  at MappedListIterable.length.W.prototype.cH(org-dartlang-sdk:///lib/internal/iterable.dart:413:31)
  at A.cp.prototype.B(org-dartlang-sdk:///lib/internal/iterable.dart:342:5)
  at A.bAO(org-dartlang-sdk:///lib/_internal/js_runtime/lib/core_patch.dart:494:5)
  at A.a9(org-dartlang-sdk:///lib/_internal/js_runtime/lib/core_patch.dart:475:39)
  at A.b_u(org-dartlang-sdk:///lib/internal/iterable.dart:213:44)
  at A.a77.prototype.gcB(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-5.2.4/lib/firebase_auth_web.dart:148:5)
  at A.Fe.prototype.gcB(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/firebase_auth-4.2.4/lib/src/firebase_auth.dart:65:19)
  at A.bqm.prototype.$2(../../../lib/core/services/user_service.dart:69:43)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:91:49)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
  at A.bp3.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:43:16)
  at A.bp2.prototype.$1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:108:14)
  at A.bp1(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/go_router-6.0.1/lib/src/redirection.dart:114:5)
```



<details>
  <summary>flutter doctor -v</summary>

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-US)
    • Flutter version 3.3.10 on channel stable at /Users/james/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 135454af32 (3 weeks ago), 2022-12-15 07:36:55 -0800
    • Engine revision 3316dd8728
    • Dart version 2.18.6
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/james/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.74.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.1 22C65 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 108.0.5359.71

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>