async function waitForPass(fn, timeout = 2000) {
	const start = Date.now();

	let error;
	while (start + timeout >= Date.now()) {
		try {
			await fn();
			return;
		} catch (err) {
			if (!ignoreError(err)) {
				error = err;
			}
		}

		// Wait a little before the next iteration
		await wait(10);
	}

	throw error ? error : new Error(`waitForPass timed out. Waited ${timeout}ms`);
}
Wait until a function doesn't throw anymmore
@param {() => any} fn
@param {number} timeout
@returns {Promise<void>}