Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network error: Cannot read property 'headers' of undefined #8

Closed
bensalilijames opened this issue Apr 23, 2017 · 7 comments
Closed
Labels

Comments

@bensalilijames
Copy link

On upgrading from 3.0.3 to 4.0.0 I get the following error:

Network error: Cannot read property 'headers' of undefined
  at new ApolloError ([...]/node_modules/apollo-client/apollo.umd.js:1851:28)

I think it should be passing options through to window.fetch as well as opts?

@jaydenseric
Copy link
Owner

@AdamYee ?

Just tried updating apollo-upload-examples to v4 and it immediately errors.

@jaydenseric
Copy link
Owner

I think this and this should not have been changed.

@AdamYee
Copy link

AdamYee commented Apr 25, 2017

Hey guys,

I was able to reproduce by removing opts from the createNetworkInterface config. Something that I didn't test because my app needs the cookies. Fetch queries (not mutations) will just fail silently, but when I attempt to upload a file I get the same error as @benhjames.

@jaydenseric so the changes to the lines you referenced are still needed, but they need to pass in an empty object when there isn't an opts defined when creating the network interface like what most people probably do at first:

const networkInterface = createNetworkInterface({
  uri: '/graphql'
});

The fix should look something like this in the network-interface.js and batch-network-interface.js files:

return _HTTPFetchNetworkInte.prototype.fetchFromRemoteEndpoint.call(this, { request: request, options: options.opts || {} });

In the meantime, if people need a quick workaround they can create the network interface with an empty opts:

const networkInterface = createNetworkInterface({
  uri: '/graphql',
  opts: {} // just to get around the 4.0.0 bug
});

😃

@jaydenseric
Copy link
Owner

This seems to be ok now on master branch.

I am getting paranoid every time I publish a new release, it's so hard to manually test everything. We really need some unit tests!

@jaydenseric
Copy link
Owner

Just released v4.0.1, please let me know if everything is happy chappy 🙏

@AdamYee
Copy link

AdamYee commented Apr 25, 2017

@jaydenseric updated to 4.0.1 and all is well.

@bensalilijames
Copy link
Author

Yep, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants