Skip to content

Commit c8066a4

Browse files
committed
Force localhost for Expo iOS dogfooding
1 parent d9c57d1 commit c8066a4

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

.agents/skills/exceptionless-javascript/references/client-react-native.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ await Exceptionless.startup((config) => {
5252
});
5353
```
5454

55-
For local simulator development, prefer `http://localhost:<port>` when the app is running in the iOS simulator. Use a LAN IP only when a physical device must reach a server on the development machine.
55+
For local simulator development, prefer `http://localhost:<port>` when the app is running in the iOS simulator. Start Expo with `--localhost` or set `REACT_NATIVE_PACKAGER_HOSTNAME=localhost` so Metro bundle URLs in stack traces also use localhost. Use a LAN IP only when a physical device must reach a server on the development machine.
5656

5757
## Error Boundary
5858

@@ -105,7 +105,7 @@ await Exceptionless.createException(new Error("Checkout failed"))
105105
## Troubleshooting
106106

107107
- If native crashes do not appear in Expo, verify the app is not running in Expo Go and that the config plugin is present before rebuilding the native app.
108-
- If simulator submissions cannot reach a local Exceptionless server, use `http://localhost:<port>` for iOS Simulator. Physical devices need a reachable LAN host.
108+
- If simulator submissions cannot reach a local Exceptionless server, use `http://localhost:<port>` for iOS Simulator and make sure Metro is not running in Expo's default LAN mode. Physical devices need a reachable LAN host.
109109
- For malformed or unexpected stacks, verify behavior in `ReactNativeErrorPlugin` tests before changing parser logic.
110110
- For native crash report loss concerns, verify `NativeCrashPlugin` only clears pending reports after at least one report is retrieved and submitted.
111111

example/expo/App.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,17 @@ function TabIcon({ label, focused }: { label: string; focused: boolean }) {
3131

3232
/**
3333
* Resolves the dev server URL based on the current platform.
34-
* - Web: localhost works directly.
35-
* - iOS Simulator: localhost reaches the host Mac.
34+
* - Web and iOS Simulator: localhost reaches the host Mac.
3635
* - Android Emulator: 10.0.2.2 reaches the host machine.
37-
* - Real devices: need the dev machine's IP, extracted from Expo's hostUri.
36+
* - Real Android devices: need the dev machine's IP, extracted from Expo's hostUri.
3837
*/
3938
function getServerUrl(): string {
40-
if (!__DEV__ || Platform.OS === "web") {
39+
if (!__DEV__ || Platform.OS === "web" || Platform.OS === "ios") {
4140
return "http://localhost:7110";
4241
}
4342

4443
if (!Device.isDevice) {
45-
return Platform.OS === "android" ? "http://10.0.2.2:7110" : "http://localhost:7110";
44+
return "http://10.0.2.2:7110";
4645
}
4746

4847
const hostUri = Constants.expoConfig?.hostUri;

example/expo/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This app tracks Expo SDK 56.
99
## Prerequisites
1010

1111
- Install dependencies from the repository root with `npm install`.
12-
- Run an Exceptionless server on `http://localhost:7110`. The example uses localhost for web/iOS Simulator, `10.0.2.2` for Android Emulator, and Expo's `hostUri` for physical devices.
12+
- Run an Exceptionless server on `http://localhost:7110`. The example uses localhost for web/iOS, `10.0.2.2` for Android Emulator, and Expo's `hostUri` for physical Android devices.
1313
- Use a development build for native iOS crash reporting.
1414

1515
## Run
@@ -21,15 +21,15 @@ npm install
2121
npm run ios --workspace=example/expo
2222
```
2323

24-
`npm run ios` runs `expo run:ios`, which prebuilds native files when needed, installs the development build, and starts Metro.
24+
`npm run ios` runs `expo run:ios`, which prebuilds native files when needed, installs the development build, and starts Metro. The script sets `REACT_NATIVE_PACKAGER_HOSTNAME=localhost` so iOS Simulator stack traces use localhost bundle URLs instead of LAN IPs.
2525

2626
For the checked-in VS Code launch profile and iPad dogfooding, use:
2727

2828
```bash
2929
npm run ios:ipad --workspace=example/expo
3030
```
3131

32-
`ios:ipad` launches the `iPad Air 11-inch (M3)` simulator on Metro port `8082`, which avoids colliding with another React Native app already using the default `8081` port.
32+
`ios:ipad` launches the `iPad Air 11-inch (M3)` simulator on Metro port `8082`, which avoids colliding with another React Native app already using the default `8081` port. It also forces the Metro hostname to localhost.
3333

3434
If the development build is already installed, start Metro directly:
3535

@@ -58,7 +58,8 @@ The in-app Logs tab should show events being enqueued and sent to the configured
5858

5959
## Notes
6060

61-
- The example points at `http://localhost:7110` by default and only derives the host IP for physical devices when Expo provides `hostUri`.
61+
- The example points at `http://localhost:7110` by default and only derives the host IP for Android physical devices when Expo provides `hostUri`.
62+
- For iOS Simulator stack traces, run Metro with `--localhost` or `REACT_NATIVE_PACKAGER_HOSTNAME=localhost`; otherwise Expo's default LAN mode can put a `10.x.x.x` URL into stack-frame file names.
6263
- Native iOS crashes are written by the native module and submitted on the next launch.
6364
- Android currently exercises JavaScript events only; Android native crash reporting is not implemented yet.
6465
- Generated native folders are intentionally ignored by `example/expo/.gitignore`; run `npm run prebuild --workspace=example/expo` or `npm run ios --workspace=example/expo` to recreate them locally.

example/expo/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"version": "3.0.0-dev",
55
"main": "./index.js",
66
"scripts": {
7-
"start": "expo start --dev-client",
8-
"start:ios": "expo start --dev-client --ios",
7+
"start": "expo start --dev-client --localhost",
8+
"start:ios": "expo start --dev-client --ios --localhost",
99
"start:web": "expo start --web",
10-
"ios": "expo run:ios",
11-
"ios:ipad": "expo run:ios --device \"iPad Air 11-inch (M3)\" --port 8082",
10+
"ios": "REACT_NATIVE_PACKAGER_HOSTNAME=localhost expo run:ios",
11+
"ios:ipad": "REACT_NATIVE_PACKAGER_HOSTNAME=localhost expo run:ios --device \"iPad Air 11-inch (M3)\" --port 8082",
1212
"web": "expo export --platform web",
1313
"prebuild": "expo prebuild --clean --no-install",
1414
"android": "expo run:android"

0 commit comments

Comments
 (0)