Chrome memory leak on dispatchEvent

		const focusEvent = new FocusEvent('focus', {
			bubbles: true	
		});

		// Trigger the input value in the search box
		const inputEvent = new InputEvent('input', {
			bubbles: true
		});

        // Send enter
		const keyEvent = new KeyboardEvent('keydown', {
			code: 'Enter',
			key: 'Enter',
			keyCode: 13,
			view: window,
			bubbles: true
		});

		let search = document.querySelector('#side > div._1Ra05 > div > label > div > div._1awRl.copyable-text.selectable-text');

		function searchList(name = "") {
			try {
				search.textContent = name;
				search.dispatchEvent(focusEvent);
				search.dispatchEvent(inputEvent);
				search.dispatchEvent(keyEvent);

				search.removeEventListener('focus', focusEvent);
				search.removeEventListener('input', inputEvent);
				search.removeEventListener('keydown', keyEvent);

			} catch { console.log(error); };
		}

I’m using puppeteer and inside await page.evaluate(async ({ i have a loop that calls the function searchList on each 100 ms, the problem is the browser mem usage is growing constantly, after 30min its over 1GB of ram.

I discovered that whos causing it is the search.dispatchEvent lines, when i comment they the mem does not increase.

I “tried” to solve it adding:

search.removeEventListener('focus', focusEvent);
search.removeEventListener('input', inputEvent);
search.removeEventListener('keydown', keyEvent);

But it did not change anything in relation to the memory increasing over time, does someone have any idea what else i could try to stop or release the memory growing?

I really don’t have much of a clue. Are many of the *Event objects being created?

maybe the section about timers/callbacks can help

I reproduced the error here: https://stackoverflow.com/questions/65410135/chrome-memory-leak
Could you take a look?

I think this is over my head but I’m interested to find out what is going on.