diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index dd19af4b..986fe124 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -45,7 +45,7 @@ import { HubSpotServices } from '../../hubspot.gblib/services/HubSpotServices'; import { WhatsappDirectLine } from '../../whatsapp.gblib/services/WhatsappDirectLine'; import { GBAdminService } from '../../admin.gbapp/services/GBAdminService'; const DateDiff = require('date-diff'); - +import { createBrowser } from '../../core.gbapp/services/GBSSR'; const Path = require('path'); const sgMail = require('@sendgrid/mail'); @@ -130,10 +130,7 @@ export class DialogKeywords { public async getPage(step, url, username, password) { GBLog.info(`BASIC: Web Automation GET PAGE ${url}.`); if (!this.browser) { - this.browser = - - // set the HTTP Basic Authentication credential - + this.browser = await createBrowser(null); } const page = await this.browser.newPage(); if (username || password) { diff --git a/packages/core.gbapp/services/GBSSR.ts b/packages/core.gbapp/services/GBSSR.ts index d2380b3a..075da8a0 100644 --- a/packages/core.gbapp/services/GBSSR.ts +++ b/packages/core.gbapp/services/GBSSR.ts @@ -39,7 +39,6 @@ const puppeteer = require('puppeteer'); const pluginStealth = require('puppeteer-extra-plugin-stealth'); import { NextFunction, Request, Response } from "express"; -import { Browser } from "puppeteer"; const Path = require('path'); // https://hackernoon.com/tips-and-tricks-for-web-scraping-with-puppeteer-ed391a63d952 @@ -82,7 +81,7 @@ const RENDER_CACHE = new Map(); -async function createBrowser(profile): Promise { +async function createBrowser(profile): Promise { const gbaiName = `${this.min.botId}.gbai`; let localName = Path.join('work', gbaiName, 'profile'); @@ -141,7 +140,7 @@ async function ssr(url: string, useCache: boolean, cacheRefreshRate: number) { }; } } - const browser = createBrowser(null); + const browser = await createBrowser(null); const stylesheetContents = {}; try {