Commit d7e77fd
authored
fix: bind setTimeout to globalThis in SupabaseBroadcastAdapter for browser compatibility (#402)
# Fix setTimeout context binding issue in SupabaseBroadcastAdapter
This PR fixes a browser compatibility issue in the `SupabaseBroadcastAdapter` class where `setTimeout` was losing its context binding when used in browser environments. The issue would cause an error: `"'setTimeout' called on an object that does not implement interface Window"`.
The fix:
- Properly binds `setTimeout` to the global context using `setTimeout.bind(globalThis)` in the constructor
- Adds comprehensive tests to verify the fix works correctly
This issue only manifested in browser environments, not in Node.js, which explains why our existing tests didn't catch it. I've added a test that simulates the browser's strict context requirements for `setTimeout`.
The PR also includes a planning document for implementing browser-based testing to catch similar issues in the future.1 parent 5dc5cfc commit d7e77fd
File tree
2 files changed
+6
-1
lines changed- .changeset
- pkgs/client/src/lib
2 files changed
+6
-1
lines changed| 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 | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
0 commit comments