Commit c7d6d9e
authored
fix(connect-react): improve extension detection with polling and prop… (#1)
* fix(connect-react): improve extension detection with polling and proper cleanup
Enhance the KleverProvider extension detection to handle cases where
window.kleverWeb is injected with a delay by browser extensions.
Changes:
- Add exponential backoff polling (50ms to 1000ms, up to 10 attempts)
- Implement proper cleanup with cancellation flag to prevent race conditions
- Add detailed debug logging for extension detection attempts
- Stop polling immediately when extension is detected
- Handle StrictMode double-mounting correctly with cleanup function
This ensures reliable extension detection in both fast and slow injection
scenarios while maintaining proper React lifecycle management.
Related: KLC-1882
* fix(ci): add pull-requests write permission to size-check workflow
The workflow needs explicit permission to comment on pull requests.
Without this, it fails with 'Resource not accessible by integration' error.
* fix(ci): save bundle size report to file for PR comment
The GITHUB_STEP_SUMMARY is not accessible between steps, so we now:
- Write the report to both GITHUB_STEP_SUMMARY and a temporary file
- Read from the file in the PR comment step
- Add fallback message if report file is empty or missing
* fix(connect-react): use ref for debug flag to satisfy React hooks rules
The useEffect for extension detection was using config?.debug without
including it in the dependency array, violating React's Rules of Hooks.
Solution: Store debug flag in a ref that updates separately, allowing:
- Access to latest debug value for logging
- No re-runs of extension detection when debug changes
- Proper React hooks compliance
This prevents ESLint warnings and potential issues in strict mode.1 parent 4fb4ab8 commit c7d6d9e
File tree
3 files changed
+102
-15
lines changed- .changeset
- .github/workflows
- packages/connect-react/src
3 files changed
+102
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| 37 | + | |
33 | 38 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
46 | | - | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
50 | 61 | | |
51 | 62 | | |
52 | 63 | | |
53 | 64 | | |
54 | 65 | | |
55 | 66 | | |
56 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
57 | 78 | | |
58 | 79 | | |
59 | 80 | | |
60 | 81 | | |
61 | 82 | | |
62 | | - | |
| 83 | + | |
63 | 84 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
253 | 268 | | |
254 | 269 | | |
255 | 270 | | |
256 | 271 | | |
257 | 272 | | |
258 | 273 | | |
259 | | - | |
260 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
261 | 305 | | |
262 | | - | |
263 | 306 | | |
264 | 307 | | |
265 | 308 | | |
266 | 309 | | |
267 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
268 | 323 | | |
269 | 324 | | |
270 | 325 | | |
| |||
0 commit comments