# Troubleshooting

> Fixes for common problems, and the limits of the connection and every panel.

## Windows blocks the first launch

* **Windows says it protected your PC?** Windows builds aren’t code-signed yet, so SmartScreen may warn on first launch. Choose **More info**, then **Run anyway**.

## The desktop app doesn’t see my app

* **Is Metro running on port 8081?** The Console and Network panels find your app through Metro’s debugger at `http://localhost:8081`. If Metro runs on another port, see [Metro isn’t on port 8081](#metro-isnt-on-port-8081).
* **Is the desktop app running on the same machine?** The SDK connects to `ws://localhost:9340`. On Android, `localhost` is the emulator or device itself. Emulators fall back to `10.0.2.2` automatically, and the desktop app forwards the port to attached devices when `adb` is installed. If a device still doesn’t connect, run `adb reverse tcp:9340 tcp:9340` yourself.
* **Is this a development build?** The SDK is inert in production builds by design. Check the exported `runtime`: it should be `'dev'`.
* **Did `init()` run?** Call it once, as early as possible in your entry file.

## Metro isn’t on port 8081

If you start Metro on another port, for example `npx expo start --port 8082`, the Console and Network panels and other Metro-backed features can’t find your app on the default port. Panels that use the SDK bridge, such as Redux and TanStack Query, still work, and the **Connection** panel shows **No Metro found on port …**. Open [**Settings > Connection**](/docs/desktop/settings/connection/) and set **Metro port** to the port Metro prints at startup. If your app uses a recent SDK and **Use the port reported by the app** is on, Xerlock picks the port up itself once the app connects. See [Ports](/docs/desktop/connection/#ports).

## The Console or Network panel is missing

They are hidden only when the SDK is connected and your app passed `console: false` or `network: false`. Remove that option, or pass `true`.

## Time travel or edits behave strangely

Both replace state wholesale, so they rely on immutable updates. Direct mutation of state corrupts the history. They also roll back state only: requests already sent and persisted writes are not undone.

## `xerlockMiddleware()` doesn’t typecheck

Make sure `xerlockMiddleware()` is the innermost middleware when combined with `devtools`, `persist` or `immer`. Xerlock’s types assume your tsconfig resolves packages the way a React Native app does, with `"customConditions": ["react-native"]`, which the Expo and React Native tsconfig presets set.

## `init` rejects my config

Config keys are checked strictly. A misspelt plugin name, an unknown key, or `true` for an opt-in plugin is a type error. See [Types](/docs/configuration/#types).

## Connection

* Xerlock connects to one app through Metro at a time, and has no way to pick between them. With several apps running, it reconnects to the last app it was connected to, otherwise the first one Metro lists.
* On Android, Xerlock forwards port `9340` to every emulator and device listed by `adb devices`, so the SDK reaches the desktop app over USB too. This needs `adb` from the Android SDK, found through `ANDROID_HOME`, `ANDROID_SDK_ROOT`, `~/Library/Android/sdk` or your `PATH`.
* On a physical iPhone, the panels that work through Metro still work, but the SDK can’t reach the desktop app, so the panels that need the SDK don’t appear. Use the iOS Simulator for those.
* **SDK** says **Version mismatch**: the SDK in your app and the desktop app don’t match. A message says which to update: **The Xerlock SDK in your app is out of date. Update @xerlock/client.** or **Your app uses a newer Xerlock SDK. Update Xerlock.**
* **SDK bridge** says **Unavailable: …**: another program is using port `9340`, such as another copy of Xerlock. Quit it and restart Xerlock.
* **Status** is connected but **SDK** says **Not connected**: check that `init` runs when your app starts, in a development build. See [How the SDK connects](/docs/desktop/connection/#how-the-sdk-connects).

## Console

* The Console keeps the latest 5,000 entries and drops older ones.
* `console.group`, `console.table` and `console.trace` show as ordinary log entries, and `console.clear()` doesn’t clear the panel.
* Entries don’t link to the source file. To see where an error came from, log the `Error` object and expand its `stack`.
* If nothing appears, check the Connection panel. “No Metro found on port …” means Metro isn’t running, or runs on a port other than the one in [**Settings > Connection**](/docs/desktop/settings/connection/).

## Native logs

* Native logs are only collected while the Native logs panel is open, and the list starts empty each time you open it. Open it before you reproduce a problem.

* The panel keeps the latest 5,000 entries. “N lines skipped” means the app logged faster than the desktop app could keep up, and some lines were dropped.

* On iOS, only simulators are supported, not physical devices. Lines logged before the panel opened aren’t shown, and neither are debug-level lines.

* On Android, emulators and devices listed by `adb devices` are supported. Opening the panel shows the app’s last 500 lines, and the panel picks the app up again after it restarts.

* If the panel shows an error instead of logs:

  * **No booted iOS simulator was found**: boot the simulator your app runs on.
  * **… is not installed on the booted simulator**: install and run your app on that simulator.
  * **No Android device or emulator is connected**: start the emulator, or connect and authorise the device.
  * **Several Android devices match this app**: close the emulators you aren’t using.

## Network

* The Network panel keeps the latest 1,000 requests and drops older ones.

* When a request is redirected, only the final response is reported. The Info tab shows its **Final URL**, and cookies set by earlier responses aren’t shown.

* Throttling only slows requests made with `fetch` or `XMLHttpRequest`. Images loaded by native components and requests made by native SDKs aren’t throttled, and `FormData` uploads get no upload delay.

* Running `init()` again while throttling is on resets throttling in your app, though the banner stays. Turn throttling off and on again to apply it.

* “React Native disabled network inspection for this app session” means React Native stopped reporting requests. Fully close and relaunch your app.

* If nothing appears, check the Connection panel. “No Metro found on port …” means Metro isn’t running, or runs on a port other than the one in [**Settings > Connection**](/docs/desktop/settings/connection/).

* On React Native below 0.83, the panel can’t read requests natively, so it shows what the SDK sees from JS and can’t show:

  * Requests made before `init()`, `<Image>` loads and requests made by native SDKs.
  * Requests made by importing `fetch` from `expo/fetch`, or through a `fetch` saved before `init()`.
  * The request’s `Cookie` header.
  * Request bodies that aren’t strings, and response bodies that aren’t text or are over 1 MB, so images have no preview.
  * Redirects. The row shows the original URL and isn’t flagged.
  * Timing beyond when the request started and ended.
  * Throttling.

## TanStack Query

* **The TanStack Query panel is missing**: pass your `QueryClient` as `tanstackQuery` in `init()`.

- Mutations are read-only, and their result isn’t shown.
- Values and array items edited one at a time are strings, numbers, booleans or `null`. To add an object or array, use **Overwrite data**.

## Debugger

* The app doesn’t pause when it throws. Set a breakpoint in the `catch` or just before the throw.
* There are no conditional breakpoints, logpoints or keyboard shortcuts for stepping.
* The Debugger attaches to one device at a time. If more than one device runs your app on the same Metro, the Connection panel shows which one it uses. Close the app on the others.
* **No sources yet**: check the app is running and the Metro port in [**Settings > Connection**](/docs/desktop/settings/connection/) matches the one Metro is on.
* **This file’s source isn’t available**: the bundle’s source map has no source for this file.

## React

* Props, state and hooks can’t be edited from the panel, and profiles can’t be saved or loaded.
* **React Native DevTools is using the component inspector**: only one tool can use React’s component inspector at a time, and React Native DevTools has taken it over. Click **Reconnect** to take it back.
* **The React panel needs React Native 0.76 or later**: the app doesn’t expose React’s developer tools. Check it is a development build.
* **Couldn’t read the component tree from the app**: click **Reconnect**.
* **Connect an app to inspect its React components**: check the app is running and the Metro port in [**Settings > Connection**](/docs/desktop/settings/connection/) matches the one Metro is on.

## Zustand

* Stores can only be registered in `init()`. A store created later doesn’t appear until `init()` runs again with it.
* **The Zustand panel is missing**: pass `zustand` to `init()`, and check that every value in `stores` is a store. One that isn’t turns the panel off.
* **Changes show keys instead of names**: add `xerlockMiddleware()` to the store, innermost of its middleware.

- Only top-level functions are listed as actions. Functions inside nested objects aren’t.

## Redux

* **The Redux panel is missing**: pass `redux` to `init()`, and create the store with `xerlockEnhancer()`.
* **Actions from thunks or middleware are missing**: put `xerlockEnhancer()` after `applyMiddleware`.
* **A type isn’t offered on the Dispatch tab**: check the console for a warning that its entry in `actions` has no `type`.

- Xerlock shows one Redux store per app.
- Before and after states are kept for the last 200 actions. Older actions can’t be diffed or unwound to.

## Storage

* **The Storage panel is missing**: pass `storage` to `init()`.
* **AsyncStorage changes don’t appear until you refresh**: pass `init()` the same AsyncStorage object your app writes with.

- SecureStore can’t list its keys. Look them up by name.
- AsyncStorage and SecureStore store strings only. MMKV stores strings, numbers and booleans.
- MMKV doesn’t record a value’s type, so the type shown is worked out from the stored value and can occasionally be wrong.
- Keys are deleted one at a time. There’s no way to clear a whole storage from the panel.
- **“The keychain is locked”**: unlock the device, then click **Retry**.

## Database

* **The panel says “No databases yet”**: pass `database` to `init()`, or add a connection.

- `BEGIN`, `COMMIT` and other transaction statements are refused.
- A query’s result shows at most 1000 rows.
- BLOB values show their size only and can’t be edited.
- **“Your app has disconnected”**: its databases leave the list, except the one you’re viewing, which stays until you leave the panel. Reconnect your app to bring them back.
- **“The SSH server’s host key has changed”**: if you trust the new key, click **Forget** beside **Pinned host key** in the connection’s settings, then connect again.

## Commands

* **The Commands panel is missing**: check that `commands` isn’t `false`.
* **“No commands on file”**: no `registerCommand()` call has run yet. Check that the file calling it is imported.

- The desktop app waits 10 seconds for a command to finish. After that it shows **The command could not be run. The app did not answer as expected.**, while the handler carries on in the app.
- A command whose `registerCommand()` call you delete stays listed until the app reloads.

## Navigation

* **No navigation commands**: check that `navigation` is set, that the ref comes from `useNavigationContainerRef()` and is passed to your navigation container, and that `init` runs in a `useEffect`. Xerlock ignores a value that isn’t a navigation ref, without an error.

- Without Expo Router, only mounted navigators are listed. A screen in a navigator that hasn’t rendered yet, such as a lazy tab you haven’t opened, appears after your app first visits it. Running a command for a name that isn’t mounted fails with `Route "…" isn't mounted right now`.
- With Expo Router, the `navigation.reset` list also includes Expo Router’s own routes, such as `__root`, `+not-found` and `_sitemap`.
- Search params are found by reading source, so they are a best guess. A key read with a computed name, such as `params[name]`, isn’t found, and files in `node_modules` aren’t read. Keys added while the app runs appear after a reload, or once the app opens the screen with them.
- `navigation.goBack` fails with `Nothing to go back to` on the first screen.
- **`navigation.navigate` and `navigation.reset` are missing** while the container hasn’t mounted. The other commands fail with `Navigation isn't ready yet` until it has.

## Notifications

* **“Add `notifications` to the Xerlock client config to deliver through the app instead.”**: the FCM broadcast failed and no handler is set. Pass `expoNotifications` or `onRemoteMessage`.
* **“The app has no handler for incoming notifications.”**: pass `expoNotifications` or `onRemoteMessage`.
* **“The app’s notification handler threw an error.”**: the toast shows the error your handler threw.

- iOS notifications can only go to an iOS Simulator, not a physical device.
- **“Couldn’t run xcrun.”**: install Xcode and its command line tools.
- **“No iOS Simulator is booted.”**: boot one, with your app running on it.
- **“Couldn’t run adb.”**: install the Android platform tools.
- **“The device hasn’t authorised this computer.”**: accept the USB debugging prompt on the device.
- **“This emulator image doesn’t allow root, which the FCM broadcast needs.”** or **“… has no FCM receiver to take the broadcast.”**: see [Sending over adb](/docs/desktop/notifications/#sending), or pass a handler to [`notifications`](/docs/sdk/notifications/) to deliver through your app.
- The panel doesn’t keep a history of sent notifications.

## Settings

### Connection

* **No Metro found on port …** in the Connection panel: Metro isn’t running, or runs on another port. Set **Metro port** to the port Metro prints when it starts.
* The SDK’s own port, `9340`, can’t be changed. See [SDK port](/docs/desktop/connection/#sdk-port).

### Environments

* **Unknown variable: …**: no variable has that name in the active environment or **Base**. Nothing is sent until it’s fixed.
* **Secret has no saved value: …**: the secret was never saved, or the keychain couldn’t be read. Type its value again.
* **Couldn’t save the secret to the keychain**: your system refused the keychain write. Check that the keychain is unlocked.
* **Add connected app** is disabled while no app is connected.

### MCP

* **Couldn’t start: …**: usually another program is using the port. Change **MCP port**, or quit the other program, and turn the server on again.
* An agent says a tool is turned off in Xerlock’s MCP settings: raise that area’s permission.
* Native logs are only collected while the Native logs panel is open.

### Version

* **Couldn’t check for updates**: the check failed, for example while offline. Click **Check for updates** to try again.
* **Couldn’t install the update**: the install failed, with the reason. The update stays ready, so you can try again.
