expo: metro bundler crashes at start with error: Error: Must specify expo-platform header or query parameter

Summary

When I start metro bundler with expo start --dev-client, Metro bundler crashes with error:

Error: Must specify expo-platform header or query parameter
    at getPlatformFromRequest (.../node_modules/expo-cli/node_modules/xdl/src/start/ExpoUpdatesManifestHandler.ts:34:11)

I have a valid develop build in eas.json:

  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
    },
 }

Managed or bare workflow? If you have made manual changes inside of the ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android, iOS

Package versions

expo-dev-client : 0.9.5 expo-updates : 0.13.1

Environment

  expo-env-info 1.0.3 environment info:
    System:
      OS: macOS 12.3.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.18.1 - /var/folders/fs/mgcn9dds60114gl150cz1fk40000gn/T/yarn--1652390571976-0.8778512103665701/node
      Yarn: 1.22.15 - /var/folders/fs/mgcn9dds60114gl150cz1fk40000gn/T/yarn--1652390571976-0.8778512103665701/yarn
      npm: 8.3.0 - ~/.nvm/versions/node/v14.18.1/bin/npm
      Watchman: 2021.11.15.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.11.3 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
    IDEs:
      Android Studio: 2020.3 AI-203.7717.56.2031.7935034
      Xcode: 13.2/13C5081f - /usr/bin/xcodebuild
    npmPackages:
      expo: ^45.0.0 => 45.0.1 
      react: 17.0.2 => 17.0.2 
      react-dom: 17.0.2 => 17.0.2 
      react-native: 0.68.1 => 0.68.1 
      react-native-web: 0.17.7 => 0.17.7 
    npmGlobalPackages:
      eas-cli: 0.52.0
      expo-cli: 5.4.3
    Expo Workflow: managed

Reproducible demo

This crash is not consistent.

  1. create a new expo project: expo init
  2. add dev-client with a development profile
  3. run expo start --dev-client

Stacktrace (if a crash is involved)


23:18
Error: Must specify expo-platform header or query parameter
    at getPlatformFromRequest (.../node_modules/expo-cli/node_modules/xdl/src/start/ExpoUpdatesManifestHandler.ts:34:11)
    at /.../node_modules/expo-cli/node_modules/xdl/src/start/ExpoUpdatesManifestHandler.ts:207:19
    at call (/.../node_modules/connect/index.js:239:7)
    at next (/.../node_modules/connect/index.js:183:5)
    at Function.handle (/.../node_modules/connect/index.js:186:3)
    at handle (/.../node_modules/connect/index.js:91:14)
    at call (/.../node_modules/connect/index.js:239:7)
    at next (/.../node_modules/connect/index.js:183:5)
    at Function.handle (/.../node_modules/connect/index.js:186:3)
    at Server.app (/.../node_modules/connect/index.js:51:37)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 36 (12 by maintainers)

Most upvoted comments

I don’t get the error until I launch Flipper Desktop.

I’m starting Metro Bundler with the Node script of npm run esd (esd = expo start dev) A development build can be created with npm run ebd (ebd = eas build dev)

I was able to reproduce this using @OneHatRepo’s example. Local builds using the simulator work, but attempting to use the custom developer client on a physical iOS device generates the Error: Must specify expo-platform header or query parameter error. I traced the error to ExpoUpdatesManifestHandler, which seems to be invoked when Flipper asks for the event log as part of metro connection.

I don’t realistically think we’re going to fix this from the flipper side. However, I was able to connect to an on-device Hermes app with the following start command which bypasses the expo update manifest:

expo start --dev-client --force-manifest-type=classic

However, I couldn’t tell you what the implications of doing this are for a custom dev client since the updates manifest is usually relevant for adhoc/testflight/production updates.

Using the minimal test app, expo run did work in generating a development build that could connect to Flipper and debug through the Hermes Debugger, but also threw me into the bare workflow, which I did not want.

Using eas build to generate a development build caused the error to return in Metro Bundler when I tried to connect through Flipper. Metro Bundler didn’t actually crash, but it continually spit out error messages like the one shown below.

Metro Bundler

Flipper sees the app but shows the Hermes debugger as unavailable, as shown.

Flipper

Here is the minimal app’s code in question: https://github.com/OneHatRepo/MetroBundlerError

I’m starting Metro Bundler with the Node script of npm run esd (esd = expo start dev) A development build can be created with npm run ebd (ebd = eas build dev)

Facing a similar issue where nothing is crashing but seeing the same errors on console

I started having this issue as well with SDK 46.

Screen Shot 2022-08-17 at 2 56 13 PM

Not stale