apollo-client: bad string formatting when constructing error - "Cannot convert object to primitive value"

Issue Description

I think there’s a bug on some code path that’s trying to construct an error. Looks similar too what was fixed in #11516, but I’m running 3.9.5 which should have that fix. I see:

index.ts:97 Uncaught (in promise) ApolloError: Cannot convert object to primitive value
    at new ApolloError2 (index.ts:97:5)
    at Object.error (QueryManager.ts:353:48)
    at notifySubscription (module.js:137:18)
    at onNotify (module.js:176:3)
    at SubscriptionObserver2.error (module.js:229:5)
    at asyncMap.ts:45:28

The underlying error returned by the server is the requested element is null which the schema does not allow.

Link to Reproduction

Reproduction Steps

No response

@apollo/client version

3.9.5

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

@Netail huh, very weird. But that’s valuable feedback, too. Thanks! I’ll keep digging

I’ll try to set up a demo, if I somehow able to reproduce it

I believe that, for some reason, Vite was using an old version of Apollo Client (different from the version in my package.json / node_modules. I’ve compared the sources the browser was reporting with what I was seeing on a different machine where the error did not reproduce, and they did not match. Deleting the node_modules/.vite fixed the problem. So I suspect that the problem had been fixed by a recent patch.

Apologies for the noise… Closing.