mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.04k stars 2.21k forks source link

JS heap dump while deploying on Netlify #11877

Open ashkanahrabi opened 2 years ago

ashkanahrabi commented 2 years ago

There's a JS heap dump issue which occurred while I was deploying a project on Netlify which uses mapbox-gl as a dependency.

mapbox-gl-js version: 2.8.2

browser: -

Steps to Trigger Behavior

  1. Install mapbox-gl@2.8.2 on your project using npm: npm install --save mapbox-gl
  2. try to deploy the project via Netlify
  3. after Netlify runs npm run build the following error shows up:
1:24:57 PM: Creating an optimized production build...
1:26:00 PM: <--- Last few GCs --->
1:26:00 PM: [1457:0x51a5700]    60975 ms: Scavenge 2034.0 (2075.6) -> 2032.3 (2080.1) MB, 2.5 / 0.0 ms  (average mu = 0.187, current mu = 0.145) allocation failure
1:26:00 PM: [1457:0x51a5700]    60983 ms: Scavenge 2036.7 (2080.3) -> 2033.1 (2080.8) MB, 2.6 / 0.0 ms  (average mu = 0.187, current mu = 0.145) allocation failure
1:26:00 PM: [1457:0x51a5700]    61002 ms: Scavenge 2037.7 (2081.3) -> 2034.1 (2082.3) MB, 12.8 / 0.0 ms  (average mu = 0.187, current mu = 0.145) allocation failure
1:26:00 PM: <--- JS stacktrace --->
1:26:00 PM: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1:26:00 PM:  1: 0xb09c10 node::Abort() [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM:  2: 0xa1c193 node::FatalError(char const*, char const*) [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM:  3: 0xcf8dbe v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM:  4: 0xcf9137 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM:  5: 0xeb09d5  [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM:  6: 0xeb14b6  [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM:  7: 0xebf9de  [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM:  8: 0xec0420 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM:  9: 0xec3315 v8::internal::Heap::HandleGCRequest() [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM: 10: 0xe509b7 v8::internal::StackGuard::HandleInterrupts() [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM: 11: 0x11fcd75 v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
1:26:00 PM: 12: 0x15f2099  [/opt/buildhome/.nvm/versions/node/v16.15.0/bin/node]
  1. try downgrading mapbox-gl to version 1.13.0 then trigger a redeploy and you'll notice there's no issue with this version

NOTE

avpeery commented 2 years ago

Hi @ashkanahrabi - thanks for reporting this issue to GL-JS! I found a similar issue previously closed #8475.

Have you tried increasing the node memory with something like export NODE_OPTIONS=--max_old_space_size=4096 or adding NODE_OPTIONS = "--max_old_space_size=4096 to a netlify.toml file? If this doesn't help, we would need further information to reproduce the issue. Do you still experience this issue when downgrading to another version of GL-JS?

Thanks for using Mapbox!

ashkanahrabi commented 2 years ago

Thanks @avpeery

I think the provided solution isn't the best practice. Maybe I'm wrong.

After downgrading to 1.13.0 the issue was gone. Seems like the issue happens only on the latest version.

Let me know of any other information needed to help you find the issue.

jkepps commented 1 year ago

I am also experiencing this issue since upgrading to v2. not only do my builds while deploying to netlify fail, but the build step for my integration tests on github actions is also failing. downgrading to 1.13.0 solves the issue