-
Notifications
You must be signed in to change notification settings - Fork 184
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
Conversation
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.
var elementPromisesOr = elementPromises.map((promise, index) => { | ||
var orPromise = Q.defer(); | ||
timeoutDfd[index] = Q.defer(); | ||
promise.then(orPromise.resolve) |
There was a problem hiding this comment.
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>"); |
There was a problem hiding this comment.
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?
This looks good to me now. Nice work @sresant! |
Relates to issue #711
The main issues addressed here are:
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.