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.

Apollo Core: TypeError: response.http.headers is not iterable

See original GitHub issue

Package: apollo-server-core@2.9.0 Expected Behavior: Well I’m not sure what to expect.

Actual Behavior: These lines in apollo-server-core are stopping my application from returning payloads to the client.

https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-core/src/runHttpQuery.ts#L309-L313

I receive the following stacktrace:

"TypeError: response.http.headers is not iterable",
              "    at /Users/<ommited>/Documents/<ommited>/<ommitted>/node_modules/apollo-server-core/src/runHttpQuery.ts:311:49",
              "    at Generator.next (<anonymous>)",
              "    at fulfilled (/Users/<ommited>/Documents/<ommited>/<ommitted>/node_modules/apollo-server-core/dist/runHttpQuery.js:4:58)",
              "    at process._tickCallback (internal/process/next_tick.js:68:7)"

When I comment out those 4 lines of code everything works normally.

I have logged what the headers look like at that point and they are the following: Headers { _headers: {} }

Seems to be some class instance of headers however, the way that the core package tries to iterate over the headers causes a type error to be thrown.

I am using apollo-server-express. Any hints as to why its unable to interface with the headers correctly?

This is the minimum code example needed to reproduce:

const app = express();
import { ApolloServer } from 'apollo-server-express';
const server = new ApolloServer({
  schema: schema,
  formatError: (err) =>{
    console.log(err);
    return err;
  },
  context: async ({ req, res, ...rest }, ...other) => {
    return {
      hi: 5
    }
  },
  introspection: true,
  tracing: false,
  cacheControl: false
});

server.applyMiddleware({ app, path: '/api', cors: corsOptions });
const httpServer = createServer(app);
httpServer.listen(PORT, () => console.log('GraphQL API running at http://localhost:3001/api'));

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
sportnakcommented, Nov 6, 2019

To provide a little more clarity, this worked for me by changing my baseUrl from . to ./ (mildly infuriating, but c’est la vie)

1reaction
stevenolaycommented, Oct 4, 2019

@duxtinto

Hey, how are you doing. I’m not sure what it could be in your specific case but in my case my baseUrl in my tsconfig was incorrect.

Which was interesting because my project compiled just fine if i went in the node modules folder and commented out the part where it was getting the "response.http.headers " is not iterable from.

But as soon as the base url was corrected… the issue magically disappeared. I know this was the issue because I pair programmed with a buddy of mine and we just kept making minor edits to the tsconfig until we could get something to work. To this day I can still reproduce the error just by changing the baseUrl.

** Shrugs **

Sorry if this isn’t of any help…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Types is not iterable - Help - Apollo GraphQL
TypeError : types is not iterable. I make a simple replication of the config I am using for. CodeSandbox – 6 Jun 21 ......
Read more >
TypeError: undefined is not iterable (cannot read property ...
just trying to render a list of items obtained from my backend but getting this error indicating it's undefined. However, when I check...
Read more >
typeerror: undefined is not iterable (cannot read ... - You.com
My page crashes only when Apollo dev tools is open. Apollo Client Developer Tools version 2.3.2 Chrome browser, Version 86.0.4240.111 (Official Build) (64-bit)....
Read more >
Fetch Standard
Any item in list that is not a forbidden response-header name. A no-CORS-safelisted request-header name is a header name that is a byte-case- ......
Read more >
TypeScript errors and how to fix them
error TS1192: Module ' json5 ' has no default export. Broken Code ❌. 1, import json5 from 'json5 ...
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