-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8169 from LedgerHQ/bugfix/LIVE-14585
fix(iOS): Solana error after broadcast on WebSockets [LIVE-14585]
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
"live-mobile": patch | ||
--- | ||
|
||
fix(iOS): Solana error after broadcast on WebSockets | ||
|
||
We are adding a missing user-agent header on the websocket for iOS with RN | ||
https://github.com/facebook/react-native/issues/28450 | ||
https://github.com/facebook/react-native/issues/30727 | ||
We need to use the interceptor as we don't control the code initiating the websocket | ||
Updating the options passed in by the interceptor works fine | ||
https://github.com/facebook/react-native/blob/3dfe22bd27429a43b4648c597b71f7965f31ca65/packages/react-native/Libraries/WebSocket/WebSocketInterceptor.js#L148-L163 | ||
Another solution could be to use pnpm to patch react native WebSocket linked below | ||
https://github.com/facebook/react-native/blob/3dfe22bd27429a43b4648c597b71f7965f31ca65/packages/react-native/Libraries/WebSocket/WebSocket.js | ||
But the interceptor seems lean enough and a simple hack vs patching a lib seems preferable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Platform } from "react-native"; | ||
// @ts-expect-error WebSocketInterceptor is not exposed by react d.ts | ||
import WebSocketInterceptor from "react-native/Libraries/WebSocket/WebSocketInterceptor.js"; | ||
|
||
// We are adding a missing user-agent header on the websocket for iOS with RN | ||
// https://github.com/facebook/react-native/issues/28450 | ||
// https://github.com/facebook/react-native/issues/30727 | ||
// We need to use the interceptor as we don't control the code initiating the websocket | ||
// Updating the options passed in by the interceptor works fine | ||
// https://github.com/facebook/react-native/blob/3dfe22bd27429a43b4648c597b71f7965f31ca65/packages/react-native/Libraries/WebSocket/WebSocketInterceptor.js#L148-L163 | ||
// Another solution could be to use pnpm to patch react native WebSocket linked below | ||
// https://github.com/facebook/react-native/blob/3dfe22bd27429a43b4648c597b71f7965f31ca65/packages/react-native/Libraries/WebSocket/WebSocket.js | ||
// But the interceptor seems lean enough and a simple hack vs patching a lib seems preferable | ||
|
||
if (Platform.OS === "ios") { | ||
WebSocketInterceptor.enableInterception(); | ||
WebSocketInterceptor.setConnectCallback( | ||
(_url: string, _protocols: string[] | null, options?: { headers?: Record<string, string> }) => { | ||
if (options) { | ||
if (!options.headers) options.headers = {}; | ||
if (!options.headers["User-Agent"]) options.headers["User-Agent"] = "ReactNative"; | ||
} | ||
}, | ||
); | ||
} |
c4f102d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Evm on Staging ($0.00) ⏲ 20s
3 critical spec errors
Spec Ethereum failed!
Spec Ethereum Sepolia failed!
Spec Ethereum Holesky failed!
Details of the 0 mutations
Spec Ethereum (failed)
Spec Ethereum Sepolia (failed)
Spec Ethereum Holesky (failed)
Details of the 9 uncovered mutations
Spec Ethereum (3)
Spec Ethereum Sepolia (3)
Spec Ethereum Holesky (3)
Portfolio ($0.00) – Details of the 3 currencies
Performance ⏲ 20s
Time spent for each spec: (total across mutations)