Skip to content

Commit b107868

Browse files
CAMOBAPclaude
andcommitted
fix: correct onMessage payload extraction and increase bridgeTimeout for CI
- SandboxReactNativeView wrapper already unwraps e.nativeEvent.data before calling onMessage, so msg IS the data directly (not msg.data). iOS sends an object, Android sends a JSON string — handle both with typeof check. - Switch beforeAll to waitFor/queryByTestId to avoid findByTestId 3-arg API - Use a sibling hidden View for sandbox-ready marker instead of passing testID directly to SandboxReactNativeView: changing testID on the native view while the sandbox is running causes the iOS sandbox to restart, leading to a native crash 39s into test execution. - Increase bridgeTimeout from default 60s to 120s so iOS CI simulator has enough time to install and boot the app after a long Xcode build Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 99c2dad commit b107868

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

apps/fs-experiment/App.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ function App(): React.JSX.Element {
114114
</Pressable>
115115
</View>
116116

117+
{sandboxReady && (
118+
<View testID="sandbox-ready" style={styles.readyMarker} />
119+
)}
117120
<SandboxReactNativeView
118-
testID={sandboxReady ? 'sandbox-ready' : undefined}
119121
style={styles.sandboxView}
120122
origin="sandbox.fs-experiment.demo"
121123
componentName="SandboxApp"
@@ -125,7 +127,8 @@ function App(): React.JSX.Element {
125127
useSubstitution ? SANDBOXED_SUBSTITUTIONS : undefined
126128
}
127129
onMessage={msg => {
128-
if (msg.cmd === 'ready') setSandboxReady(true)
130+
const payload = typeof msg === 'string' ? JSON.parse(msg) : msg
131+
if (payload?.cmd === 'ready') setSandboxReady(true)
129132
console.log('Host received from sandbox:', msg)
130133
}}
131134
onError={err =>
@@ -142,6 +145,10 @@ const styles = StyleSheet.create({
142145
root: {
143146
flex: 1,
144147
},
148+
readyMarker: {
149+
width: 0,
150+
height: 0,
151+
},
145152
section: {
146153
borderBottomWidth: StyleSheet.hairlineWidth,
147154
},

apps/fs-experiment/__tests__/sandbox-isolation.harness.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
expect,
99
it,
1010
render,
11+
waitFor,
1112
} from 'react-native-harness'
1213

1314
import App from '../App'
@@ -86,9 +87,14 @@ describe('Substitution OFF', () => {
8687
beforeAll(async () => {
8788
blockCleanup = true
8889
await render(<App />, {timeout: RENDER_TIMEOUT})
89-
await screen.findByTestId('sandbox-ready', {
90-
timeout: SANDBOX_READY_TIMEOUT,
91-
})
90+
await waitFor(
91+
() => {
92+
if (!screen.queryByTestId('sandbox-ready')) {
93+
throw new Error('Sandbox not ready')
94+
}
95+
},
96+
{timeout: SANDBOX_READY_TIMEOUT}
97+
)
9298
}, SANDBOX_READY_TIMEOUT + RENDER_TIMEOUT)
9399

94100
if (isIOS) {

apps/fs-experiment/rn-harness.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const config = {
3333
forwardClientLogs: true,
3434
resetEnvironmentBetweenTestFiles: true,
3535
disableViewFlattening: true,
36+
bridgeTimeout: 120_000,
3637
}
3738

3839
export default config

0 commit comments

Comments
 (0)