kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: close browser on error
rodzic
aeb0ce7cab
commit
8043e652f1
|
@ -59,6 +59,7 @@ export class ChatGPTAPIBrowser {
|
||||||
this._browser = null
|
this._browser = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
this._browser = await getBrowser({ captchaToken: this._captchaToken })
|
this._browser = await getBrowser({ captchaToken: this._captchaToken })
|
||||||
this._page =
|
this._page =
|
||||||
(await this._browser.pages())[0] || (await this._browser.newPage())
|
(await this._browser.pages())[0] || (await this._browser.newPage())
|
||||||
|
@ -71,6 +72,16 @@ export class ChatGPTAPIBrowser {
|
||||||
page: this._page,
|
page: this._page,
|
||||||
isGoogleLogin: this._isGoogleLogin
|
isGoogleLogin: this._isGoogleLogin
|
||||||
})
|
})
|
||||||
|
} catch (err) {
|
||||||
|
if (this._browser) {
|
||||||
|
await this._browser.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
this._browser = null
|
||||||
|
this._page = null
|
||||||
|
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
|
||||||
const chatUrl = 'https://chat.openai.com/chat'
|
const chatUrl = 'https://chat.openai.com/chat'
|
||||||
const url = this._page.url().replace(/\/$/, '')
|
const url = this._page.url().replace(/\/$/, '')
|
||||||
|
|
Ładowanie…
Reference in New Issue