Commit 501a33b
authored
Prevent setTimeout from firing if we can't match devtools user agent (#13349)
Fixes #13344
The `connectToDevtools` method inside `ApolloClient` runs a `setTimeout`
then checks the `window.navigator.userAgent` to see if it matches a
supported platform before logging the message. As #13344 points out,
this can be problematic in test environments since that `setTimeout` can
linger. Even worse is when that `setTimeout` outlives the virtual DOM
construction so `window` doesn't exist anymore which could cause
crashes.
This fix checks `window.navigator.userAgent` outside the `setTimeout`
and prevents it from scheduling if we're in a non Chrome/Firefox
environment.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved Apollo DevTools extension prompts by displaying them only in
supported browser contexts.
* Prevented unnecessary extension suggestions in embedded frames and
unsupported protocols.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 4bb6df7 commit 501a33b
2 files changed
Lines changed: 31 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1169 | 1169 | | |
1170 | 1170 | | |
1171 | 1171 | | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
1172 | 1188 | | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
1176 | 1193 | | |
1177 | 1194 | | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
1199 | 1201 | | |
1200 | 1202 | | |
1201 | 1203 | | |
| |||
0 commit comments