From fed1c97112d3173012a33a2d56a45e9546800b41 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Sun, 17 Dec 2017 14:38:35 -0800 Subject: [PATCH] Fix page hot loading fixes #3255 (#3256) --- .../internal-plugins/query-runner/pages-writer.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js b/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js index 86ef1079d23d4..fb698e963ada9 100644 --- a/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js +++ b/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js @@ -152,6 +152,18 @@ const debouncedWritePages = _.debounce( 500, { leading: true } ) +emitter.on(`CREATE_PAGE`, () => { + // Ignore CREATE_PAGE until bootstrap is finished + // as this is called many many times during bootstrap and + // we can ignore them until CREATE_PAGE_END is called. + // + // After bootstrap, we need to listen for this as stateful page + // creators e.g. the internal plugin "component-page-creator" + // calls createPage directly so CREATE_PAGE_END won't get fired. + if (bootstrapFinished) { + debouncedWritePages() + } +}) emitter.on(`CREATE_PAGE_END`, () => { debouncedWritePages()