{"action":"created","issue":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6349","repository_url":"https://api.github.com/repos/gatsbyjs/gatsby","labels_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6349/labels{/name}","comments_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6349/comments","events_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6349/events","html_url":"https://github.com/gatsbyjs/gatsby/issues/6349","id":339561091,"node_id":"MDU6SXNzdWUzMzk1NjEwOTE=","number":6349,"title":"Building many pages exhausts memory","user":{"login":"tfausak","id":408753,"node_id":"MDQ6VXNlcjQwODc1Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/408753?v=4","gravatar_id":"","url":"https://api.github.com/users/tfausak","html_url":"https://github.com/tfausak","followers_url":"https://api.github.com/users/tfausak/followers","following_url":"https://api.github.com/users/tfausak/following{/other_user}","gists_url":"https://api.github.com/users/tfausak/gists{/gist_id}","starred_url":"https://api.github.com/users/tfausak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfausak/subscriptions","organizations_url":"https://api.github.com/users/tfausak/orgs","repos_url":"https://api.github.com/users/tfausak/repos","events_url":"https://api.github.com/users/tfausak/events{/privacy}","received_events_url":"https://api.github.com/users/tfausak/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2018-07-09T18:35:41Z","updated_at":"2018-10-01T15:11:10Z","closed_at":"2018-07-09T18:47:55Z","author_association":"NONE","body":"## Description\r\n\r\nGatsby is running out of memory when building a site with many (2,500+) pages.\r\n\r\n### Steps to reproduce\r\n\r\nGiven the files below, run:\r\n\r\n``` sh\r\n$ env GATSBY_PAGE_COUNT=2600 npm run build\r\n```\r\n\r\nThe exact number (2600) required to trigger the failure fluctuates. It's usually around 2556 or so. Using 2500 always succeeds for me, and 2600 always fails. \r\n\r\n### Expected result\r\n\r\nThe site should be built. \r\n\r\n### Actual result\r\n\r\nThe site fails to build because Node runs out of memory.\r\n\r\n```\r\n$ env GATSBY_PAGE_COUNT=2600 time npm run build \r\n\r\n> @ build /.../example\r\n> rm -f -r .cache public public.tar public.tar.gz && gatsby build && tar -c -f public.tar public && gzip -f -k public.tar\r\n\r\nsuccess delete html and css files from previous builds — 0.008 s\r\nsuccess open and validate gatsby-config — 0.004 s\r\nsuccess copy gatsby files — 0.015 s\r\n⠁ Generating 2600 pages ...\r\nsuccess onPreBootstrap — 0.012 s\r\nsuccess source and transform nodes — 0.011 s\r\nsuccess building schema — 0.058 s\r\nsuccess createLayouts — 0.005 s\r\nsuccess createPages — 4.298 s\r\nsuccess createPagesStatefully — 0.205 s\r\nsuccess onPreExtractQueries — 0.000 s\r\nsuccess update schema — 0.112 s\r\nsuccess extract queries from components — 0.010 s\r\nsuccess run graphql queries — 0.703 s\r\nsuccess write out page data — 0.033 s\r\nsuccess write out redirect data — 0.001 s\r\nsuccess onPostBootstrap — 0.000 s\r\n\r\ninfo bootstrap finished - 6.568 s\r\n\r\nsuccess Building CSS — 2.919 s\r\nsuccess Building production JavaScript bundles — 26.349 s\r\n⢀ Building static HTML for pages\r\n<--- Last few GCs --->\r\n\r\n[23516:0x104002400]    49209 ms: Mark-sweep 951.3 (1453.8) -> 951.3 (1437.8) MB, 122.6 / 0.0 ms  (average mu = 0.006, current mu = 0.000) last resort GC in old space requested\r\n[23516:0x104002400]    49341 ms: Mark-sweep 951.3 (1437.8) -> 951.3 (1437.8) MB, 131.5 / 0.0 ms  (average mu = 0.003, current mu = 0.001) last resort GC in old space requested\r\n\r\n\r\n<--- JS stacktrace --->\r\n\r\n==== JS stack trace =========================================\r\n\r\n    0: ExitFrame [pc: 0x33656ef841bd]\r\nSecurity context: 0x16c4e671e6c9 <JSObject>\r\n    1: DoJoin(aka DoJoin) [0x16c47a34cf41] [native array.js:~87] [pc=0x33656f9fa0a2](this=0x16c4769822e1 <undefined>,l=0x16c4bb354d91 <JSArray[2]>,m=2,A=0x16c476982381 <true>,w=0x16c476982441 <String[0]: >,v=0x16c4769823f1 <false>)\r\n    2: Join(aka Join) [0x16c47a34cf91] [native array.js:~112] [pc=0x33656f9b5534](this=0x16c4769822e1 <undefined>,l=0x16c4bb354d...\r\n\r\nFATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory\r\n 1: 0x100033aa9 node::Abort() [/usr/local/bin/node]\r\n 2: 0x100035236 node::FatalTryCatch::~FatalTryCatch() [/usr/local/bin/node]\r\n 3: 0x10017a8fb v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]\r\n 4: 0x10017a89d v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]\r\n 5: 0x1004532f2 v8::internal::Heap::UpdateSurvivalStatistics(int) [/usr/local/bin/node]\r\n 6: 0x100459823 v8::internal::Heap::AllocateRawWithRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]\r\n 7: 0x100439204 v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]\r\n 8: 0x100671682 v8::internal::Runtime_StringBuilderConcat(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]\r\n 9: 0x33656ef841bd \r\nsh: line 1: 23516 Abort trap: 6           gatsby build\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! errno 134\r\nnpm ERR! @ build: `rm -f -r .cache public public.tar public.tar.gz && gatsby build && tar -c -f public.tar public && gzip -f -k public.tar`\r\nnpm ERR! Exit status 134\r\nnpm ERR! \r\nnpm ERR! Failed at the @ build script.\r\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR!     /.../.npm/_logs/2018-07-09T18_22_01_979Z-debug.log\r\n       51.12 real        60.16 user         6.52 sys\r\n```\r\n\r\n### Environment\r\n\r\n```\r\n  System:\r\n    OS: macOS High Sierra 10.13.5\r\n    CPU: x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz\r\n    Shell: 3.2.57 - /bin/bash\r\n  Binaries:\r\n    Node: 10.6.0 - /usr/local/bin/node\r\n    npm: 6.1.0 - /usr/local/bin/npm\r\n  Browsers:\r\n    Chrome: 67.0.3396.99\r\n    Firefox: 59.0.2\r\n    Safari: 11.1.1\r\n  npmPackages:\r\n    gatsby: 1.9.273 => 1.9.273 \r\n    gatsby-cli: 1.1.58 => 1.1.58 \r\n```\r\n\r\n### File contents\r\n\r\n`package.json`:\r\n``` json\r\n{\r\n  \"dependencies\": {\r\n    \"gatsby\": \"1.9.273\",\r\n    \"gatsby-cli\": \"1.1.58\"\r\n  },\r\n  \"scripts\": {\r\n    \"build\": \"rm -f -r .cache public public.tar public.tar.gz && gatsby build && tar -c -f public.tar public && gzip -f -k public.tar\"\r\n  }\r\n}\r\n```\r\n\r\n`gatsby-node.js`: \r\n``` js\r\nconst path = require('path');\r\nconst count = process.env.GATSBY_PAGE_COUNT || 2600;\r\nconsole.log(`Generating ${count} page${count === 1 ? '' : 's'} ...`);\r\nexports.createPages = (gatsby) => {\r\n  const component = path.resolve('template.js');\r\n  for (let number = 1; number <= count; number += 1) {\r\n    gatsby.boundActionCreators.createPage({\r\n      component,\r\n      path: `/numbers/${number}`,\r\n      context: { number },\r\n    });\r\n  }\r\n};\r\n```\r\n\r\n`template.js`:\r\n``` js\r\nimport React from 'react';\r\nexport default class NumberPage extends React.Component {\r\n  render() {\r\n    return (\r\n      <p> This is the number page for { this.props.pathContext.number }. </p>\r\n    );\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/comments/425944034","html_url":"https://github.com/gatsbyjs/gatsby/issues/6349#issuecomment-425944034","issue_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6349","id":425944034,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTk0NDAzNA==","user":{"login":"amykapernick","id":15953185,"node_id":"MDQ6VXNlcjE1OTUzMTg1","avatar_url":"https://avatars2.githubusercontent.com/u/15953185?v=4","gravatar_id":"","url":"https://api.github.com/users/amykapernick","html_url":"https://github.com/amykapernick","followers_url":"https://api.github.com/users/amykapernick/followers","following_url":"https://api.github.com/users/amykapernick/following{/other_user}","gists_url":"https://api.github.com/users/amykapernick/gists{/gist_id}","starred_url":"https://api.github.com/users/amykapernick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amykapernick/subscriptions","organizations_url":"https://api.github.com/users/amykapernick/orgs","repos_url":"https://api.github.com/users/amykapernick/repos","events_url":"https://api.github.com/users/amykapernick/events{/privacy}","received_events_url":"https://api.github.com/users/amykapernick/received_events","type":"User","site_admin":false},"created_at":"2018-10-01T15:11:10Z","updated_at":"2018-10-01T15:11:10Z","author_association":"NONE","body":"@DSchau  I've installed the plugin, I'm using it as a submodule as they're still working on it. I'll have a look and see if I can add it a different way"}}
{"actor":{"display_login":"amykapernick"}}