taiko
taiko copied to clipboard
Memory leak when a browser tab is opened/closed repeatedly
Describe the bug There is a memory leak in Taiko(?) that occurs when a new browser tab is open/closed repeatedly. As a result of the leak, Gauge script crashes after a few minutes. The issue is observed with Taiko v 1.2.8. It appears that the issue is not reproducible with Taiko v 1.0.8.
To Reproduce Steps (or script) to reproduce the behavior:
- Go to '.https://joulecma.ca/cpg/homepage/browse-by/category/conditions/id/488'
- Click on 'Dismiss'
- Scroll down to '1.'
- Repeat 200 times: Click on link with text '1.' The link opens in a new tab. Close tab
- See error: (node:4582) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 Target.targetCreated listeners added to [Chrome]. Use emitter.setMaxListeners() to increase limit (node:4582) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disconnect listeners added to [Chrome]. Use emitter.setMaxListeners() to increase limit (node:4582) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 Network.requestWillBeSent listeners added to [Chrome]. Use emitter.setMaxListeners() to increase limit ... The message above comes up 100s of times until the crash <--- Last few GCs ---> [4582:0x104918000] 300036 ms: Scavenge (reduce) 4085.5 (4100.3) -> 4085.3 (4101.5) MB, 5.2 / 0.0 ms (average mu = 0.195, current mu = 0.213) allocation failure [4582:0x104918000] 300044 ms: Scavenge (reduce) 4085.9 (4104.0) -> 4085.9 (4104.0) MB, 5.9 / 0.0 ms (average mu = 0.195, current mu = 0.213) allocation failure [4582:0x104918000] 300054 ms: Scavenge (reduce) 4086.7 (4100.5) -> 4086.5 (4102.0) MB, 6.8 / 0.0 ms (average mu = 0.195, current mu = 0.213) allocation failure <--- JS stacktrace ---> FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0x101326b05 node::Abort() (.cold.1) [/usr/local/bin/node] 2: 0x1000b7129 node::Abort() [/usr/local/bin/node] 3: 0x1000b729f node::OnFatalError(char const*, char const*) [/usr/local/bin/node] 4: 0x100201c27 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node] 5: 0x100201bc3 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node] 6: 0x1003b1d95 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node] 7: 0x1003b385a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node] 8: 0x1003aef29 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node] 9: 0x1003ac7c1 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node] 10: 0x1003bb09a v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node] 11: 0x1003bb121 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node] 12: 0x1003887b2 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node] 13: 0x1007086e8 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node] 14: 0x100a97899 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
//Gauge script
"use strict";
const {
openBrowser,
goto,
click,
link,
closeTab,
scrollDown
} = require('taiko');
step("Iterate articles", async function() {
await openBrowser({
headless: true
})
await goto('https://joulecma.ca/cpg/homepage/browse-by/category/conditions/id/488');
await click("Dismiss")
await await scrollDown('1.')
for (var count = 1; count < 200 ; count++) {
console.log (count.toString())
await click(link('1.'));
await closeTab();
}
});
Logs
See above
Expected behavior The script runs without an issue
Screenshots If applicable, add screenshots to help explain your problem.
Versions:
- Taiko: 1.2.8
- OS 10.15.7, Docker node:14.19-slim (FROM node:14.19-slim)
- Node.js v14.19.0
gauge -v
Gauge version: 1.4.1
Plugins
-------
html-report (4.0.12)
java (0.7.9)
js (2.3.17)
screenshot (0.0.1)
Thank you for the detailed report @siarhei-cma . We had a similar issue reported but that was because of the taiko-screencast plugin. Just wanted to check if you are using any plugins with taiko?
I did not install any taiko plugins. Below is a screenshot of node_modeules folder:

thanks again @siarhei-cma - I can replicate this issue. I'll look deeper
@siarhei-cma Can you please try version 1.3.2
Hi! Thank you @saikrishna321. I am sorry for the delay. I tried with v 1.3.2 and still have the same issue.