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

fix(koa): don't hang when body is already parsed #780

Merged
merged 1 commit into from
Jun 21, 2018
Merged

Conversation

benjie
Copy link
Member

@benjie benjie commented Jun 21, 2018

Previously if you had bodyParser in your Koa middleware stack before PostGraphile, e.g.

const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const { postgraphile } = require('postgraphile');

const app = new Koa();
app.use(bodyParser()); // < this!
app.use(postgraphile());
app.listen(3000);

then PostGraphile (well, strictly it was body-parser itself) would hang whilst processing GraphQL requests because it didn't realise that the request body had already been consumed.

I've added some additional middleware which converts the Koa body parsing over to something that looks like Connect body parsing (it has to manipulate the ctx.req object to achieve this - sorry!); this should solve this issue.

Remember: Koa support is experimental! When raising issues please include a minimal reproduction test case (such as the one above) to help me get to the root of the issue faster.

Fixes #602

@benjie benjie merged commit 3463742 into master Jun 21, 2018
@benjie benjie deleted the fix-koa-body-parser branch June 21, 2018 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant