feat: garbage collection chromium browser on close()

pull/4/head
Travis Fischer 2022-12-04 04:33:17 -06:00
rodzic 727099a76e
commit cdd71d7ab4
1 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -48,6 +48,10 @@ export class ChatGPTAPI {
async init(opts: { auth?: 'blocking' | 'eager' } = {}) {
const { auth = 'eager' } = opts
if (this._browser) {
await this.close()
}
this._browser = await chromium.launchPersistentContext(this._userDataDir, {
headless: this._headless
})
@ -184,7 +188,9 @@ export class ChatGPTAPI {
}
async close() {
return await this._browser.close()
await this._browser.close()
this._page = null
this._browser = null
}
protected async _getInputBox(): Promise<any> {