Commit 025f9682 authored by Travis Fischer's avatar Travis Fischer

fix: timeouts for browser

parent 504d8d51
...@@ -262,7 +262,10 @@ export class ChatGPTAPIBrowser { ...@@ -262,7 +262,10 @@ export class ChatGPTAPIBrowser {
const markdownMessages = htmlMessages.map((messageHtml) => { const markdownMessages = htmlMessages.map((messageHtml) => {
// parse markdown from message HTML // parse markdown from message HTML
messageHtml = messageHtml.replace('Copy code</button>', '</button>') messageHtml = messageHtml
.replaceAll('Copy code</button>', '</button>')
.replace(/Copy code\s*<\/button>/gim, '</button>')
return html2md(messageHtml, { return html2md(messageHtml, {
ignoreTags: [ ignoreTags: [
'button', 'button',
......
...@@ -71,7 +71,7 @@ export async function getOpenAIAuth({ ...@@ -71,7 +71,7 @@ export async function getOpenAIAuth({
} }
await page.goto('https://chat.openai.com/auth/login', { await page.goto('https://chat.openai.com/auth/login', {
waitUntil: 'networkidle0' waitUntil: 'networkidle2'
}) })
// NOTE: this is where you may encounter a CAPTCHA // NOTE: this is where you may encounter a CAPTCHA
...@@ -93,7 +93,8 @@ export async function getOpenAIAuth({ ...@@ -93,7 +93,8 @@ export async function getOpenAIAuth({
// click login button and wait for navigation to finish // click login button and wait for navigation to finish
await Promise.all([ await Promise.all([
page.waitForNavigation({ page.waitForNavigation({
waitUntil: 'networkidle0' waitUntil: 'networkidle2',
timeout: timeoutMs
}), }),
page.click('#__next .btn-primary') page.click('#__next .btn-primary')
...@@ -134,7 +135,8 @@ export async function getOpenAIAuth({ ...@@ -134,7 +135,8 @@ export async function getOpenAIAuth({
await Promise.all([ await Promise.all([
waitForConditionOrAtCapacity(page, () => waitForConditionOrAtCapacity(page, () =>
page.waitForNavigation({ page.waitForNavigation({
waitUntil: 'networkidle0' waitUntil: 'networkidle2',
timeout: timeoutMs
}) })
), ),
submitP() submitP()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment