Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Chatgpt Puppeteer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Chatgpt Puppeteer
Commits
bfa0a90a
Commit
bfa0a90a
authored
Dec 25, 2022
by
Skippy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix double call to refreshSession() on 403
parent
1090fd8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
src/chatgpt-api-browser.ts
src/chatgpt-api-browser.ts
+6
-1
No files found.
src/chatgpt-api-browser.ts
View file @
bfa0a90a
...
...
@@ -32,6 +32,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
protected
_browser
:
Browser
protected
_page
:
Page
protected
_proxyServer
:
string
protected
_isRefreshing
:
boolean
/**
* Creates a new client for automating the ChatGPT webapp.
...
...
@@ -95,6 +96,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
this
.
_nopechaKey
=
nopechaKey
this
.
_executablePath
=
executablePath
this
.
_proxyServer
=
proxyServer
this
.
_isRefreshing
=
false
if
(
!
this
.
_email
)
{
const
error
=
new
types
.
ChatGPTError
(
'
ChatGPT invalid email
'
)
...
...
@@ -280,7 +282,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
}
if
(
url
.
endsWith
(
'
/conversation
'
))
{
if
(
status
===
403
)
{
if
(
status
===
403
&&
!
this
.
_isRefreshing
)
{
await
this
.
refreshSession
()
}
}
else
if
(
url
.
endsWith
(
'
api/auth/session
'
))
{
...
...
@@ -327,6 +329,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
* Attempts to handle 403 errors by refreshing the page.
*/
async
refreshSession
()
{
this
.
_isRefreshing
=
true
console
.
log
(
`ChatGPT "
${
this
.
_email
}
" session expired (403); refreshing...`
)
try
{
if
(
!
this
.
_minimize
)
{
...
...
@@ -372,6 +375,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
`ChatGPT "
${
this
.
_email
}
" error refreshing session`
,
err
.
toString
()
)
}
finally
{
this
.
_isRefreshing
=
false
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment