Skip to content

Commit

Permalink
Convert Buffer.byteLength to string before assigning to `Content-Le…
Browse files Browse the repository at this point in the history
…ngth`. (#956)

This change seems necessary in order to meet the new type definitions for
`res.setHeader` which mandate that the argument be a string, or an array of
strings.  Those type definitions were introduced via the `@types/node@9`
series of typing updates provided in [0], [1], [2].

With any luck, this will fix the failures being exhibited in CircleCI
tests[3] after we landed those typing updates.

[0]: #907
[1]: #927
[2]: #939
[3]: https://circleci.com/gh/apollographql/apollo-server/1587
  • Loading branch information
abernix committed Apr 11, 2018
1 parent a8c2af0 commit c2bba6b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/apollo-server-express/src/expressApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export function graphqlExpress(
}).then(
gqlResponse => {
res.setHeader('Content-Type', 'application/json');
res.setHeader('Content-Length', Buffer.byteLength(gqlResponse, 'utf8'));
res.setHeader(
'Content-Length',
Buffer.byteLength(gqlResponse, 'utf8').toString(),
);
res.write(gqlResponse);
res.end();
},
Expand Down

0 comments on commit c2bba6b

Please sign in to comment.