danger / danger-js

⚠️ Stop saying "you forgot to …" in code review
http://danger.systems/js/
MIT License
5.26k stars 368 forks source link

Danger regularly runs out of memory in GitHub Actions #985

Closed dkundel closed 4 years ago

dkundel commented 4 years ago

Hi there,

I'm running Danger for a project using GitHub Actions. For most of the time this worked great but recently it started crashing on every run because it's running out of memory. There hasn't been any changes to the GitHub workflow file or to the Dangerfile.

You can find an example of the error here https://github.com/twilio-labs/open-pixel-art/pull/1946/checks?check_run_id=426717243

Full error message
2020-02-05T02:21:23.1759542Z npx danger ci --text-only -f
2020-02-05T02:21:23.1795388Z shell: /bin/bash -e {0}
2020-02-05T02:21:23.1795497Z env:
2020-02-05T02:21:23.1796296Z   GITHUB_TOKEN: ***
2020-02-05T02:21:23.1796411Z ##[endgroup]
2020-02-05T02:22:11.7558013Z 
2020-02-05T02:22:11.7594992Z <--- Last few GCs --->
2020-02-05T02:22:11.7595163Z 
2020-02-05T02:22:11.7596016Z [2949:0x36c5cf0]    45683 ms: Scavenge 1139.9 (1437.5) -> 1139.3 (1442.0) MB, 9.3 / 0.0 ms  (average mu = 0.084, current mu = 0.073) allocation failure 
2020-02-05T02:22:11.7596870Z [2949:0x36c5cf0]    46291 ms: Mark-sweep 1146.3 (1442.0) -> 1133.8 (1437.5) MB, 583.0 / 0.0 ms  (average mu = 0.087, current mu = 0.089) allocation failure scavenge might not succeed
2020-02-05T02:22:11.7597634Z [2949:0x36c5cf0]    46344 ms: Scavenge 1146.9 (1437.5) -> 1146.8 (1440.5) MB, 17.8 / 0.0 ms  (average mu = 0.087, current mu = 0.089) allocation failure 
2020-02-05T02:22:11.7597818Z 
2020-02-05T02:22:11.7597886Z 
2020-02-05T02:22:11.7598487Z <--- JS stacktrace --->
2020-02-05T02:22:11.7598572Z 
2020-02-05T02:22:11.7598786Z ==== JS stack trace =========================================
2020-02-05T02:22:11.7598877Z 
2020-02-05T02:22:11.7599074Z Security context: 0x281c7c21e6e9 
2020-02-05T02:22:11.7599358Z     0: builtin exit frame: concat(this=0x341c7f357021 ,0x2402b59c34c1 ,0x341c7f357021 )
2020-02-05T02:22:11.7599458Z 
2020-02-05T02:22:11.7600095Z     1: dist(aka dist) [0x111c8ac2ded9] [/home/runner/work/open-pixel-art/open-pixel-art/node_modules/rfc6902/diff.js:~129] [pc=0x3037882fdf9d](this=0x069fa99826f1 <>,i=262,j=559)
2020-02-05T02:22:11.7600511Z     2: dist(aka dist) [0x111c8ac2ded9] [/home/runner/work/open-pi...
2020-02-05T02:22:11.7600605Z 
2020-02-05T02:22:11.7600664Z 
2020-02-05T02:22:11.7607475Z FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
2020-02-05T02:22:11.7608207Z  1: 0x8fa090 node::Abort() [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7608534Z  2: 0x8fa0dc  [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7609036Z  3: 0xb0039e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7609505Z  4: 0xb005d4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7609836Z  5: 0xef4ae2  [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7610285Z  6: 0xef4be8 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7610753Z  7: 0xf00cc2 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7611254Z  8: 0xf015f4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7611768Z  9: 0xf04261 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7612687Z 10: 0xecd356 v8::internal::Factory::AllocateRawArray(int, v8::internal::PretenureFlag) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7612921Z 
2020-02-05T02:22:11.7617076Z 11: 0xecdbda v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::Heap::RootListIndex, int, v8::internal::Object*, v8::internal::PretenureFlag) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7617725Z 12: 0xece167 v8::internal::Factory::NewFixedArrayWithHoles(int, v8::internal::PretenureFlag) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7617962Z 
2020-02-05T02:22:11.7620608Z 13: 0xb987c0  [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7620864Z 
2020-02-05T02:22:11.7625796Z 14: 0xb990f7 v8::internal::Builtin_ArrayConcat(int, v8::internal::Object**, v8::internal::Isolate*) [/opt/hostedtoolcache/node/10.18.1/x64/bin/node]
2020-02-05T02:22:11.7627722Z 15: 0x30378805bf7d 
2020-02-05T02:22:11.7628989Z 
2020-02-05T02:22:59.3601818Z Error:  Error: Got no results back from the Dangerfile evaluation, this is likely an issue with a custom sub-process exiting early.
2020-02-05T02:22:59.3603069Z     at Executor. (/home/runner/work/open-pixel-art/open-pixel-art/node_modules/danger/distribution/runner/Executor.js:140:35)
2020-02-05T02:22:59.3603804Z     at step (/home/runner/work/open-pixel-art/open-pixel-art/node_modules/danger/distribution/runner/Executor.js:32:23)
2020-02-05T02:22:59.3604489Z     at Object.next (/home/runner/work/open-pixel-art/open-pixel-art/node_modules/danger/distribution/runner/Executor.js:13:53)
2020-02-05T02:22:59.3615901Z     at /home/runner/work/open-pixel-art/open-pixel-art/node_modules/danger/distribution/runner/Executor.js:7:71
2020-02-05T02:22:59.3616355Z     at new Promise ()
2020-02-05T02:22:59.3617078Z     at __awaiter (/home/runner/work/open-pixel-art/open-pixel-art/node_modules/danger/distribution/runner/Executor.js:3:12)
2020-02-05T02:22:59.3617876Z     at Executor.handleResults (/home/runner/work/open-pixel-art/open-pixel-art/node_modules/danger/distribution/runner/Executor.js:134:16)
2020-02-05T02:22:59.3618634Z     at Object. (/home/runner/work/open-pixel-art/open-pixel-art/node_modules/danger/distribution/commands/utils/runDangerSubprocess.js:161:47)
2020-02-05T02:22:59.3619337Z     at step (/home/runner/work/open-pixel-art/open-pixel-art/node_modules/danger/distribution/commands/utils/runDangerSubprocess.js:43:23)
2020-02-05T02:22:59.3628653Z     at Object.next (/home/runner/work/open-pixel-art/open-pixel-art/node_modules/danger/distribution/commands/utils/runDangerSubprocess.js:24:53)
2020-02-05T02:22:59.3803109Z ##[error]Process completed with exit code 1.

            
        
    
            
orta commented 4 years ago

I'm not seeing this on the typescript website which is using danger-js - is it possibly the work your doing in the dangerfile?

dkundel commented 4 years ago

I tried to debug it locally by running npx danger pr ... against one of the PRs that was failing. It seems like it's failing during the step where I call danger.git.JSONPatchForFile('_data/pixels.json');.

So it seems to be an internal danger issue.

https://github.com/twilio-labs/open-pixel-art/blob/cb8c912bd45c9bf07931ab82f5975ee57306b699/dangerfile.js#L225

dkundel commented 4 years ago

If you want to replicate it, you can clone https://github.com/twilio-labs/open-pixel-art and run npx danger pr https://github.com/twilio-labs/open-pixel-art/pull/1943

orta commented 4 years ago

Cool, thanks for the repro!

dkundel commented 4 years ago

I think I found some additional info. This error seems to happen if people do a change to the JSON at the bottom while it's passing if it's in the middle.

dkundel commented 4 years ago

@orta do you have an update on this? It's breaking the experience of Open Pixel Art :(

orta commented 4 years ago

Nope, you're welcome to look into it 👍

dkundel commented 4 years ago

Great! I'll try to work on it live on Friday at 1pm PT on twitch.tv/dkundel. Let's see how that goes

orta commented 4 years ago

Woo! Good luck!