question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible Unhandled Promise Rejection (id: 0). How to handle these warnings? Where do they come from?

See original GitHub issue

Intended outcome:

I can’t tell where and why warning is thrown in the code.

Actual outcome:

Stacktrace is absolutely cryptic. No chances to understand why and where warning is thrown.

What is The provided key element? What schema is does this warning says about? Mutation has two of them: UpdateMutation and GetQuery? Which one?

    this.props.client.mutate({
      mutation: UpdateMutation,
      refetchQueries: [{ query: GetQuery }],

screen shot 2018-09-03 at 12 07 28 pm

Can you tell me where this warning happened?

Does your Apollo have means to show where this warning is thrown?

This happens after mutation.

Versions

  System:
    OS: macOS High Sierra 10.13.4
  Binaries:
    Node: 8.11.3 - /usr/local/bin/node
    npm: 5.6.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 68.0.3440.106
    Safari: 11.1
  npmPackages:
    apollo-boost: ^0.1.4 => 0.1.10 
    apollo-cache-inmemory: ^1.1.0 => 1.2.5 
    apollo-client: ^2.0.3 => 2.3.5 
    apollo-link: ^1.0.3 => 1.2.2 
    apollo-link-http: ^1.2.0 => 1.5.4 
    react-apollo: ^2.1.1 => 2.1.9

Similar issue https://github.com/apollographql/apollo-client/issues/3858 Same https://github.com/apollographql/apollo-client/issues/431 Same https://github.com/apollographql/apollo-client/issues/423

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
mlarchercommented, Dec 20, 2019

This issue is still there with 2.6.8 !

Code is working fine, but tests crash with cryptic message.

Adding a .catch() call after the mutation call is working fine, but feels like a gross hack.

Any chance to get this handled in the module ? As @joelgetaction stated, we shouldn’t get a rejected promise there, as it is already handled and the error is available from the useMutation error field to deal with !

Here is the output when testing the module with Jest and react-testing-library:

/Users/somatt/www/hm/_hm/app/client/node_modules/react-dom/cjs/react-dom.development.js:302
      var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We
                         ^

TypeError: Cannot read property 'createEvent' of null
    at Object.invokeGuardedCallbackDev (/Users/somatt/www/hm/_hm/app/client/node_modules/react-dom/cjs/react-dom.development.js:302:26)
    at invokeGuardedCallback (/Users/somatt/www/hm/_hm/app/client/node_modules/react-dom/cjs/react-dom.development.js:440:31)
    at flushPassiveEffectsImpl (/Users/somatt/www/hm/_hm/app/client/node_modules/react-dom/cjs/react-dom.development.js:25350:7)
    at unstable_runWithPriority (/Users/somatt/www/hm/_hm/app/client/node_modules/scheduler/cjs/scheduler.development.js:818:12)
    at runWithPriority$2 (/Users/somatt/www/hm/_hm/app/client/node_modules/react-dom/cjs/react-dom.development.js:12130:10)
    at flushPassiveEffects (/Users/somatt/www/hm/_hm/app/client/node_modules/react-dom/cjs/react-dom.development.js:25319:12)
    at Object.<anonymous>.flushWork (/Users/somatt/www/hm/_hm/app/client/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1039:10)
    at Immediate.<anonymous> (/Users/somatt/www/hm/_hm/app/client/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1050:11)
    at processImmediate (internal/timers.js:439:21)
(node:28822) UnhandledPromiseRejectionWarning: TypeError: Caught error after test environment was torn down

Cannot read property 'createEvent' of null
(node:28822) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:28822) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This error breaks all the test suite, which crashes on that output.

2reactions
nedgarcommented, Feb 4, 2019

this is a violation of the principle of least surprise

I have to agree. With react-apollo ^2.3.2 I’m able to avoid this by giving a dummy function to Mutation’s onError prop, e.g.

        <Mutation
          mutation={MUMUMUMYMUTATION}
          variables={{...}}
          onError={err => null} // handled below
        >
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native: Possible unhandled promise rejection
js code. The url is fine and giving me the correct json data. I can see with console log that both region.latitude and...
Read more >
Handling those unhandled promise rejections with JS async ...
You put your code inside an async function in order to use await calls; One of your await ed functions fails (i.e. rejects...
Read more >
Tracking Unhandled Promise Rejections - TrackJS
When a promise is rejected, it looks for a rejection handler. If it finds one, like in the example above, it calls the...
Read more >
React Native Auth0 Possible Unhandled Promise Rejection
In setting up samples, I've made some progress with the docs, but I've come into this error. Possible Unhandled Promise Rejection (id: 1): ......
Read more >
Possible Unhandled Promise Rejection (id: 0): | Mendix Forum
I have upgraded a native mobile app with NFC dependency from 8.6.9 (all working well) to 8.18.4. I built a new dev .apk...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found