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 timeout error handling #716

Merged
merged 3 commits into from
Nov 10, 2016
Merged

Fix timeout error handling #716

merged 3 commits into from
Nov 10, 2016

Conversation

sresant
Copy link
Contributor

@sresant sresant commented Oct 14, 2016

Relates to issue #711

The main issues addressed here are:

  1. When renderMiddleware timesout, it will send down what ever it has left but it fails to close out the body and html.
  2. In ClientController there is a race condition between nodeArrival and failArrival. nodeArrival will receive a bunch of nodes since before failArrival is sent the nodes we have left are sent down. If failArrival runs an resolves retVal before the nodes can actually render the _previouslyRender flag will be set. Once that is set and the elements try to render, because _previouslyRender is set at the point _cleanup will be called which will wipe away everything on the page.

@sresant sresant changed the title Implement fix for issue 711 Fixes timeout error handling Oct 14, 2016
The main issues addressed here are:

1. When renderMiddleware timesout, it will send down what ever it has
left but it fails to close out the body and html.

2. In ClientController there is a race condition between nodeArrival and
failArrival. nodeArrival will receive a bunch of nodes since before
failArrival is sent the nodes we have left are sent down. If failArrival
runs an resolves `retVal` before the nodes can actually render the
`_previouslyRender` flag will be set. Once that is set and the elements
try to render, because `_previouslyRender` is set at the point
`_cleanup` will be called which will wipe away everything on the page.
@sresant sresant changed the title Fixes timeout error handling Fix timeout error handling Oct 14, 2016
@sresant sresant added the bug An issue with the system label Oct 14, 2016
var elementPromisesOr = elementPromises.map((promise, index) => {
var orPromise = Q.defer();
timeoutDfd[index] = Q.defer();
promise.then(orPromise.resolve)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs rejection handling, too, right?

promise.catch(orPromise.reject);

@@ -736,6 +736,8 @@ function writeBody(req, res, context, start, page) {

// Let the client know it's not getting any more data.
renderScriptsAsync([{ text: `__reactServerClientController.failArrival()` }], res)
// Close off the body since the page life cycle will not complete
res.write("</div></body></html>");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is enough. It's addressing the symptom (we're not sending the close tags) rather than the cause (we're short-circuiting out of the normal control flow, which includes sending the close tags).

Can we handle individual element render failures without rejecting the writeBody return promise?

@gigabo
Copy link
Contributor

gigabo commented Nov 10, 2016

This looks good to me now. Nice work @sresant!

@gigabo gigabo merged commit fae947c into redfin:master Nov 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants