Apollo-client: Uncaught DOMException: Failed to execute 'postMessage' on 'Window'

Created on 11 Jul 2017  路  11Comments  路  Source: apollographql/apollo-client

  • could be related to #1871

I have afterware on my apollo client to handle errors in my app. In order to check the server's response status I have to clone the response. It was working fine until suddenly (chrome update?) I started getting this message:
DOMException: Failed to execute 'postMessage' on 'Window': Error: Network request failed with status 401 - "Unauthorized" could not be cloned.
(the error is the response from the server).

To replicate, create an afterware that clones the response from the server.

Thanks!

Most helpful comment

Seems to be a problem with the apollo devtools. Had to disable the extension in chrome.

All 11 comments

Updated to latest, also getting:

VM57:13 Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'Window': DOMException object could not be cloned.
    at ApolloClient.hookLogger [as devToolsHookCb] (<anonymous>:13:12)
    at http://localhost:3000/vendor.378cdad4168a0cb6b158.js:78529:27
    at Object.dispatch (http://localhost:3000/vendor.378cdad4168a0cb6b158.js:24413:16)
    at QueryManager.fetchQuery (http://localhost:3000/vendor.378cdad4168a0cb6b158.js:78803:20)
    at QueryManager.startQuery (http://localhost:3000/vendor.378cdad4168a0cb6b158.js:79108:14)
    at ObservableQuery.setUpQuery (http://localhost:3000/vendor.378cdad4168a0cb6b158.js:24197:27)
    at ObservableQuery.onSubscribe (http://localhost:3000/vendor.378cdad4168a0cb6b158.js:24149:18)
    at ObservableQuery.subscriberFunction (http://localhost:3000/vendor.378cdad4168a0cb6b158.js:23923:26)
    at ObservableQuery.Observable.subscribe (http://localhost:3000/vendor.378cdad4168a0cb6b158.js:50196:50)
    at GraphQL.subscribeToQuery (http://localhost:3000/app.378cdad4168a0cb6b158.js:16621:63)

Seems to be a problem with the apollo devtools. Had to disable the extension in chrome.

Yep, that worked, thanks.
Leaving this open until the issue is resolved.

I'm seeing something similar, but with Error writing result to store for query as the underlying error:

Caught an exception! DOMException: Failed to execute 'postMessage' on 'Window': Error: Error writing result to store for query

Disabling the extension solved the issue for me as well.

@ramyanaga have we fixed this?

@jazzdragon I'm going to close this and move it to the Apollo-devtools repo 馃憤 thanks!

This my case
Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'Window': Error: GraphQL error: Whoops. Looks like an internal server error

I'm getting the same error, I don't even have apollo devtools installed in my browser (using chrome).

image

Still getting this error (don't have the Chrome extension installed). Any guesses?

Same here, after a mutation throws an error (user error) I get the message

DOMException: Failed to execute 'postMessage' on 'Window': Error: GraphQL error

I'm using Chrome with the Apollo Dev Tools enabled

I finally got it to work, this is what my client related code looks like. Hope it helps someone.

const httpLink = createHttpLink({ uri: 'https://xxx.com/graphql' });

const token = localStorage.getItem('id_token'); 
const middleware = new ApolloLink((operation, forward) => {
  // add the authorization to the headers
  operation.setContext({
    headers: {
      Authorization: `Bearer ${token}`,
    } 
  });
  return forward(operation);
})

const client = new ApolloClient({
  link: concat(middleware, httpLink),
  cache: new InMemoryCache({
    dataIdFromObject: o => o.uuid
  })
});
Was this page helpful?
0 / 5 - 0 ratings