Repository: pedroslopez/whatsapp-web.js
File: src/Client.js (JavaScript)

Code before:
            const getQrCode = async () => {
                // Check if retry button is present
                var QR_RETRY_SELECTOR = 'div[data-ref] > span > button';
                var qrRetry = await page.$(QR_RETRY_SELECTOR);
                if (qrRetry) {
                    await qrRetry.click();
                }

                // Wait for QR Code
                const QR_CANVAS_SELECTOR = 'canvas';
                await page.waitForSelector(QR_CANVAS_SELECTOR, { timeout: this.options.qrTimeoutMs });
                const qrImgData = await page.$eval(QR_CANVAS_SELECTOR, canvas => [].slice.call(canvas.getContext('2d').getImageData(0, 0, 264, 264).data));
                const qr = jsQR(qrImgData, 264, 264).data;
                
                /**
                * Emitted when the QR code is received
                * @event Client#qr
                * @param {string} qr QR Code
                */
                this.emit(Events.QR_RECEIVED, qr);

                if (this.options.qrMaxRetries > 0) {
                    qrRetries++;
                    if (qrRetries > this.options.qrMaxRetries) {
                        this.emit(Events.DISCONNECTED, 'Max qrcode retries reached');
                        this.destroy();
                    }
                }
            };
            getQrCode();
            this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);

            // Wait for code scan
            await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
            clearInterval(this._qrRefreshInterval);
            this._qrRefreshInterval = undefined;

        }

        await page.evaluate(ExposeStore, moduleRaid.toString());

        // Get session tokens
        const localStorage = JSON.parse(await page.evaluate(() => {
            return JSON.stringify(window.localStorage);
        }));

        const session = {
            WABrowserId: localStorage.WABrowserId,
            WASecretBundle: localStorage.WASecretBundle,
            WAToken1: localStorage.WAToken1,
            WAToken2: localStorage.WAToken2

Review comment (suggestion):
```suggestion
                        await this.destroy();
```

Code after:
            const getQrCode = async () => {
                // Check if retry button is present
                var QR_RETRY_SELECTOR = 'div[data-ref] > span > button';
                var qrRetry = await page.$(QR_RETRY_SELECTOR);
                if (qrRetry) {
                    await qrRetry.click();
                }

                // Wait for QR Code
                const QR_CANVAS_SELECTOR = 'canvas';
                await page.waitForSelector(QR_CANVAS_SELECTOR, { timeout: this.options.qrTimeoutMs });
                const qrImgData = await page.$eval(QR_CANVAS_SELECTOR, canvas => [].slice.call(canvas.getContext('2d').getImageData(0, 0, 264, 264).data));
                const qr = jsQR(qrImgData, 264, 264).data;
                
                /**
                * Emitted when the QR code is received
                * @event Client#qr
                * @param {string} qr QR Code
                */
                this.emit(Events.QR_RECEIVED, qr);

                if (this.options.qrMaxRetries > 0) {
                    qrRetries++;
                    if (qrRetries > this.options.qrMaxRetries) {
                        this.emit(Events.DISCONNECTED, 'Max qrcode retries reached');
                        await this.destroy();
                    }
                }
            };
            getQrCode();
            this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);

            // Wait for code scan
            await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
            clearInterval(this._qrRefreshInterval);
            this._qrRefreshInterval = undefined;

        }

        await page.evaluate(ExposeStore, moduleRaid.toString());

        // Get session tokens
        const localStorage = JSON.parse(await page.evaluate(() => {
            return JSON.stringify(window.localStorage);
        }));

        const session = {
            WABrowserId: localStorage.WABrowserId,
            WASecretBundle: localStorage.WASecretBundle,
            WAToken1: localStorage.WAToken1,
            WAToken2: localStorage.WAToken2