Skip to content

Commit

Permalink
Fix #123 - request paused on exit
Browse files Browse the repository at this point in the history
It appears that subsequent operations which have the effect of pausing the
request are already queued for this event frame. This rux adds setImmediate to
push stream resumption to the next frame.

In the future, we should run tests with a small payload AND one that exceeds the
maximum TCP packet size limit and node internal buffer. This would help identify
this kind of bug.
  • Loading branch information
mike-marcacci committed Nov 16, 2018
1 parent e0ff3d0 commit 8064e47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/processRequest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ export const processRequest = (
if (!upload.file) upload.reject(exitError)

request.unpipe(parser)
request.resume()
setImmediate(() => {
request.resume()
})
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ t.test('Invalid ‘operations’ JSON.', async t => {

body.append('operations', '{ variables: { "file": null } }')
body.append('map', JSON.stringify({ 1: ['variables.file'] }))
body.append('1', 'a', { filename: 'a.txt' })
body.append('1', 'a'.repeat(70000), { filename: 'a.txt' })

const { status } = await fetch(`http://localhost:${port}`, {
method: 'POST',
Expand Down

0 comments on commit 8064e47

Please sign in to comment.