Need help: Apollo Error only in EAS Build, not in expo go

After finally upgrading my app to SDK 44 and switching from classic build to EAS, I have a strange error in my built apk.
This appears only in the app built by EAS. The app works as it shoud in expo Go.

Whenever I execute a query or mutation with Apollo GraphQL Client, I get this error:

{
  graphQLErrors: [],
  clientErrors: [],
  networkError: {
    line: 1316,
    column: 190,
    sourceURL: "index.android.bundle"
  },
  message: "Object is not a constructor (evaluating 'new o.Observable')",
  line: 826,
  column 578:,
  sourceURL: "index.android.bundle"
}

I verified the apollo client configuration via sentry messages and could not find any difference to the development app in expo go.
The Stacktrace in sentry lists no files from my project, mainly from expo and apollo client.
So I don’t really have an idea where to start debugging.
I’d be really glad if you’d have any hint or idea where to continue my search for this error.

Stacktrace from sentry:

Error: Object is not a constructor (evaluating 'new o.Observable')
  at ApolloError(node_modules/@apollo/client/errors/errors.cjs:34:28)
  at call(node_modules/@apollo/client/core/core.cjs:1124:101)
  at notifySubscription(/home/expo/workingdir/build/node_modules/zen-observable/lib/Observable.js:140:18)
  at onNotify(/home/expo/workingdir/build/node_modules/zen-observable/lib/Observable.js:179:3)
  at call(/home/expo/workingdir/build/node_modules/zen-observable/lib/Observable.js:240:7)
  at notifySubscription(/home/expo/workingdir/build/node_modules/zen-observable/lib/Observable.js:140:18)
  at onNotify(/home/expo/workingdir/build/node_modules/zen-observable/lib/Observable.js:179:3)
  at value(/home/expo/workingdir/build/node_modules/zen-observable/lib/Observable.js:240:7)
  at forEach([native code])
  at iterateObserversSafely(node_modules/@apollo/client/utilities/utilities.cjs:969:25)
  at call(node_modules/@apollo/client/utilities/utilities.cjs:1068:21)
  at notifySubscription(/home/expo/workingdir/build/node_modules/zen-observable/lib/Observable.js:140:18)
  at onNotify(/home/expo/workingdir/build/node_modules/zen-observable/lib/Observable.js:179:3)
  at error(/home/expo/workingdir/build/node_modules/zen-observable/lib/Observable.js:240:7)
  at call(node_modules/@apollo/client/link/retry/retry.cjs:79:38)
  at step(/home/expo/workingdir/build/node_modules/tslib/tslib.js:143:27)
  at next(/home/expo/workingdir/build/node_modules/tslib/tslib.js:124:57)
  at fulfilled(/home/expo/workingdir/build/node_modules/tslib/tslib.js:114:62)
  at tryCallOne(/home/expo/workingdir/build/node_modules/promise/setimmediate/core.js:37:12)
  at callback(/home/expo/workingdir/build/node_modules/promise/setimmediate/core.js:123:15)
  at _callTimer(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:123:7)
  at _callImmediatesPass(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:177:5)
  at _immediatesCallback(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:437:12)
  at __callImmediates(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:388:12)
  at fn(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:132:12)
  at __guard(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:365:9)
  at value(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:131:10)
  at value([native code])
  at value([native code])

Hi @michaelfuermann

Maybe try running it locally in production mode to see if you get more information on the error:

See the “Hint” here: Debugging - Expo Documentation

Thanks for that hint.
I ran the app with --minify --no-dev, but it worked perfectly.
So the error still appears in the build only.

Problem solved.

When upgrading expo to SDK 44, I also upgraded Apollo Client to 3.5.
Because the stacktrace mainly mentioned apollo code, I further upgraded @apollo/client to the latest version. And suddenly I could reproduce the error in development with non-minified code and a hint to a “apollo_link_1” function.

So I checked my links and found one link still using onError from apollo-link-error, that was moved into @apollo/client in v3.0. After changing that import to the onError link from @apollo/client, my app works great.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.