From 052e3329df67c89d65d5716d5e1d11823161ab15 Mon Sep 17 00:00:00 2001 From: vinsewah Date: Fri, 16 Sep 2016 15:07:41 -0700 Subject: [PATCH] Moved call to set the page on the response logger from (#659) renderMiddleware(onNavigate) to Navigator.handlePage. This will include all logs leading up to and during the execution the handleRoute method. --- packages/react-server/core/context/Navigator.js | 7 ++++++- packages/react-server/core/renderMiddleware.js | 5 +---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/react-server/core/context/Navigator.js b/packages/react-server/core/context/Navigator.js index c14d3a129..28cecb85b 100644 --- a/packages/react-server/core/context/Navigator.js +++ b/packages/react-server/core/context/Navigator.js @@ -5,7 +5,8 @@ var EventEmitter = require('events').EventEmitter, Q = require('q'), History = require("../components/History"), ReactServerAgent = require("../ReactServerAgent"), - PageUtil = require("../util/PageUtil"); + PageUtil = require("../util/PageUtil"), + {setResponseLoggerPage} = SERVER_SIDE ? require('../logging/response') : { setResponseLoggerPage: () => {} }; var _ = { isFunction: require('lodash/isFunction'), @@ -184,6 +185,10 @@ class Navigator extends EventEmitter { isRawResponse : false, }); + // Set the page context on the response logger so it can figure + // out whether to flush logs to the response document + setResponseLoggerPage(page); + // call page.handleRoute(), and use the resulting code to decide how to // respond. // We call it in a promise handler so any exception that diff --git a/packages/react-server/core/renderMiddleware.js b/packages/react-server/core/renderMiddleware.js index 435c681b5..6e496fba6 100644 --- a/packages/react-server/core/renderMiddleware.js +++ b/packages/react-server/core/renderMiddleware.js @@ -17,7 +17,7 @@ var logger = require('./logging').getLogger(__LOGGER__), StringEscapeUtil = require('./util/StringEscapeUtil'), {getRootElementAttributes} = require('./components/RootElement'), {PAGE_CSS_NODE_ID, PAGE_LINK_NODE_ID, PAGE_CONTENT_NODE_ID, PAGE_CONTAINER_NODE_ID} = require('./constants'), - {setResponseLoggerPage, flushLogsToResponse} = require('./logging/response'); + {flushLogsToResponse} = require('./logging/response'); var _ = { map: require('lodash/map'), @@ -132,9 +132,6 @@ module.exports = function(server, routes) { return; } } - // Set the page context on the response logger so it can figure - // out whether to flush logs to the response document - setResponseLoggerPage(page); renderPage(req, res, context, start, page); });