playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Open flora8984461 opened this issue 1 year ago • 20 comments

System info

  • Playwright Version: "@playwright/experimental-ct-react17": "^1.33.0"
  • Operating System: Windows 11
  • Browser: All
  • Other info: I am using Experimental: components

Source code

  • [x] I provided exact source code that allows reproducing the issue locally.

Link to the GitHub repository with the repro

https://github.com/flora8984461/reproduce-jest-failure/tree/reproduce-playwright-out-of-memory

Steps

  1. clone the repo, checkout branch: reproduce-playwright-out-of-memory, and run yarn and then yarn test-ct.

Expected

Run the test properly.

Or provide any configs to allow the test run properly.

Actual It crashes during bundle phase with the following error:

✓ 1505 modules transformed.

<--- Last few GCs --->

[8908:00000215E683B3A0]    61960 ms: Mark-sweep 4039.1 (4138.8) -> 4036.2 (4138.8) MB, 2008.2 / 0.0 ms  (average mu = 0.560, current mu = 0.050) allocation failure scavenge might not succeed
[8908:00000215E683B3A0]    65264 ms: Mark-sweep 4051.9 (4138.8) -> 4049.5 (4165.3) MB, 3295.0 / 0.0 ms  (average mu = 0.303, current mu = 0.003) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF614B10AAF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+124015
 2: 00007FF614A9C866 v8::internal::wasm::WasmCode::safepoint_table_offset+64182
 3: 00007FF614A9D8E2 v8::internal::wasm::WasmCode::safepoint_table_offset+68402
 4: 00007FF6153D1CE4 v8::Isolate::ReportExternalAllocationLimitReached+116
 5: 00007FF6153BC2AD v8::SharedArrayBuffer::Externalize+781
 6: 00007FF61525F88C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
 7: 00007FF61525C9A4 v8::internal::Heap::CollectGarbage+4244
 8: 00007FF61525A320 v8::internal::Heap::AllocateExternalBackingStore+2000
 9: 00007FF61527EEA6 v8::internal::Factory::NewFillerObject+214
10: 00007FF614FB1645 v8::internal::DateCache::Weekday+1797
11: 00007FF61545F9C1 v8::internal::SetupIsolateDelegate::SetupHeap+494417
12: 00000215E89B71FA
error Command failed with exit code 134.

Notes There is some open issue in vite and fluentui:

  • https://github.com/microsoft/fluentui/issues/25547
  • https://github.com/microsoft/fluentui/issues/24952
  • https://github.com/vitejs/vite/issues/2433

It happens when I add @fluentui/react-icons. After taking a look at the open issue, seems I can skip bundle for @fluentui/react-icons. I am not sure if there is an option to set playwright to do that when it bundles.

I am looking for any suggestions to workaround it. Your help is really appreciated 🙏

I notice there are some similar issues but they got closed without any solutions.

flora8984461 avatar May 10 '23 18:05 flora8984461

In case it helps in the interim, I've changed the test-ct script to increase the memory allocation for node: NODE_OPTIONS=--max-old-space-size=8192 playwright test -c playwright-ct.config.ts. There might be a better solution than that. Our company project tests some large sections of UI with component tests, and we've had to bump the memory from the beginning.

I'm curious if the playwright team has suggestions / guidance on "how much UI is too much to component test", or at what point a JS bundle passed around in node could be problematic for performance. I'm guessing overall the component tests are pretty memory intensive given how the JS bundle is served from node => browser. In our case, the main JS bundle is 8.8MB (1.7MB gzipped).

peterkrieg avatar May 10 '23 20:05 peterkrieg

NODE_OPTIONS=--max-old-space-size does not work well for me. I increased a few numbers but still got the same error. Then I tried a very large number and got:

vite v4.3.5 building for production...
✓ 1505 modules transformed.
[vite:build-import-analysis] Invalid string length
RangeError: Invalid string length

    at encode$1 (E:\projects\jest-react-testing-library-forked\node_modules\vite\dist\node\chunks\dep-934dbc7c.js:6213:27)
    at SourceMap (E:\projects\jest-react-testing-library-forked\node_modules\vite\dist\node\chunks\dep-934dbc7c.js:14950:19)
    at MagicString.generateMap (E:\projects\jest-react-testing-library-forked\node_modules\vite\dist\node\chunks\dep-934dbc7c.js:15266:10)
    at Object.renderChunk (E:\projects\jest-react-testing-library-forked\node_modules\vite\dist\node\chunks\dep-934dbc7c.js:45188:32)
    at E:\projects\jest-react-testing-library-forked\node_modules\rollup\dist\es\shared\node-entry.js:24551:40

  3 skipped

flora8984461 avatar May 11 '23 01:05 flora8984461

Works for me:

> playwright test -c playwright-ct.config.ts


Running 3 tests using 3 workers
  3 passed (4.1s)

To open last HTML report run:

  npx playwright show-report

pfeldman@pfeldman-mac2 reproduce-jest-failure % 

pavelfeldman avatar May 11 '23 18:05 pavelfeldman

I am surprised it works for you. I see your OS is Mac. Do you see transforming logs from vite? Thank you! I increased a lot number for my NODE_OPTIONS, either getting out of heap error or Invalid string length 😢

image

Works for me:

> playwright test -c playwright-ct.config.ts


Running 3 tests using 3 workers
  3 passed (4.1s)

To open last HTML report run:

  npx playwright show-report

pfeldman@pfeldman-mac2 reproduce-jest-failure % 

flora8984461 avatar May 11 '23 18:05 flora8984461

@pavelfeldman I asked my teammate to try and he gets out of memo as well. We are on windows

flora8984461 avatar May 11 '23 20:05 flora8984461

I can keep it open to see if others comment on the issue. It works for me with the default options, no NODE_OPTIONS required.

pavelfeldman avatar May 13 '23 00:05 pavelfeldman

A little more info to provide, I tried with my Mac mini (8g or 16g ram?) and gets out of memo still.

flora8984461 avatar May 15 '23 17:05 flora8984461

Same problem

env: macOS: 13.4.1 playwright *: 1.35.1 Browser: All info: test vue3 sfc

litingyes avatar Jun 30 '23 02:06 litingyes

Same problem for some specific websites. (But I don't know what website it is, because I'm crawling a lot of websites...)

1049451037 avatar Oct 17 '23 03:10 1049451037

same problem.

Fatal error in , line 0 Fatal process out of memory: Zone FailureMessage Object: 0000009B3F3F6190 com.microsoft.playwright.PlaywrightException: Failed to read message from driver, pipe closed.

pavankumardmg avatar Nov 14 '23 09:11 pavankumardmg

Got the below error and we are using C# dot net with playwright and version 1.39 and this problem is failing the build everytime.

locally everything runs fine.. problem happen in agent

Fatal error in , line 0

Fatal process out of memory: Zone

#FailureMessage Object: 00000067569F5790 1: 00007FF7D28C194F 2: 00007FF7D27D6B2F 3: 00007FF7D3697142 4: 00007FF7D32DD393 5: 00007FF7D2E09190 6: 00007FF7D36CF9C0 7: 00007FF7D37834BA 8: 00007FF7D3787A55 9: 00007FF7D37F65FD 10: 00007FF7D37F33BB 11: 00007FF7D37F401F 12: 00007FF7D37E114F 13: 00007FF7D3745A27 14: 00007FF7D374334C 15: 00007FF7D373E47A 16: 00007FF7D325F141 17: 00007FF7D3232DC4 18: 00007FF7D323366F 19: 00007FF7D27D950D 20: 00007FF7D290DC3D 21: 00007FF7D3928890 22: 00007FFADD174DE0 23: 00007FFADDCDED9B

gauravkhuraana avatar Nov 22 '23 09:11 gauravkhuraana

I have been using playwright 1.39.0 along with pytest and python. Considering the NODE OPTIONS is out of scope in python, what are the alternatives?

rakeshnambiar avatar Dec 23 '23 12:12 rakeshnambiar

The sampe problem for me. I played with different configurations and found, that it stops working correctly from version 1.40 of Playwright. In Task Explorer I see, that memory for Node JS process is growing constantly (such as CPU), and when process is taking a bit more than 4Gb, it aborted. Logs look like: image

Stacktrace:

image

Env:

OS: Windows 11 / Debian 12.5 Browser: Chrome Playwright: >= 1.40

AlehYanushkevich avatar Mar 18 '24 13:03 AlehYanushkevich

Experiencing the same problem as @AlehYanushkevich. Has anyone found a solution?

Zaynas-gif avatar Apr 08 '24 13:04 Zaynas-gif

image I'm having the same issue on Pipeline and locally. In version 1.39, I don't have any issues In version 1.40, I start to get this error In my investigation, I suspect the main problem is related to a huge array generated with more than 32648 items. You can see the suspect in the video below https://ingeniousbuild.rewatch.com/video/ejqrdp8bpwsnm4bp-joao-dias-s-screen-recording-09-04-2024

JoaoPDias avatar Apr 09 '24 18:04 JoaoPDias

I am getting the same issue but only on the pipeline - locally is OK Using version 1.43 Tests run ok for about 10 minutes then

2024-04-11T18:44:47.9316679Z -> error: Timeout 20000ms exceeded. 2024-04-11T18:44:47.9317222Z Call log: 2024-04-11T18:44:47.9317764Z - navigating to "https://www.thepensionsregulator.gov.uk/", waiting until "load" (34.3s) 2024-04-11T19:39:45.8919986Z <--- Last few GCs ---> 2024-04-11T19:39:45.8921513Z [13764:00000287D65FB190] 3121142 ms: Scavenge 13.6 (14.8) -> 12.8 (14.8) MB, 0.37 / 0.00 ms (average mu = 0.999, current mu = 0.996) task; 2024-04-11T19:39:45.8923745Z [13764:00000287D65FB190] 3180078 ms: Scavenge 13.6 (14.8) -> 12.8 (14.8) MB, 0.35 / 0.00 ms (average mu = 0.999, current mu = 0.996) task; 2024-04-11T19:39:45.8924656Z [13764:00000287D65FB190] 3238952 ms: Scavenge 13.6 (14.8) -> 12.8 (14.8) MB, 0.38 / 0.00 ms (average mu = 0.999, current mu = 0.996) task; 2024-04-11T19:39:45.8925185Z <--- JS stacktrace ---> 2024-04-11T19:39:45.8926342Z FATAL ERROR: Committing semi space failed. Allocation failed - JavaScript heap out of memory 2024-04-11T19:39:45.8927257Z ----- Native stack trace -----

AQuarton avatar Apr 12 '24 06:04 AQuarton