Skip to content

Commit e06cdcf

Browse files
committed
Add error check start/stop mechanism for page handling
Introduced `StartErrorCheck` and `StopErrorCheck` methods to manage error-checking states for pages. Updated relevant YAML workflows and internal logic to utilize these methods, ensuring error checks are more controlled and dynamic.
1 parent 6532c7f commit e06cdcf

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

internal/api/handlers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ func (h *APIHandlers) handleContextCanceled(instanceIndex int, page *chrome.Page
326326
log.Error(err)
327327
return
328328
}
329+
330+
r.SetVariable("PAGE", page, "ptr")
329331
err = r.Run("context_canceled")
330332
if err != nil {
331333
log.Error(err)

internal/browser/chrome/page.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type Page struct {
3232
URL string
3333
alive bool
3434
Error chan error
35+
IsErrorCheck bool
3536
}
3637

3738
func NewPage(manager *Manager, adapterName string, url string, authFilePath string, pageLoaded func(), sniffURLs ...[]string) (*Page, error) {

internal/method/sniff.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ func (m *Method) ResponseData(page *chrome.Page, channel chan *adapter.AdapterRe
2222
func (m *Method) ResponseError(page *chrome.Page, err string) {
2323
page.Error <- fmt.Errorf(err)
2424
}
25+
26+
func (m *Method) StartErrorCheck(page *chrome.Page) {
27+
page.IsErrorCheck = true
28+
}
29+
30+
func (m *Method) StopErrorCheck(page *chrome.Page) {
31+
page.IsErrorCheck = false
32+
}

internal/runner/manager.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ func NewRunnerManager(appConfigInstance config.AppConfigInstance, page *chrome.P
5757
go func() {
5858
for page.Alive() {
5959
time.Sleep(1 * time.Second)
60-
err = runner.Run("error_check")
61-
if err != nil {
62-
log.Debugf("error_check failed: %v", err)
60+
if page.IsErrorCheck {
61+
err = runner.Run("error_check")
62+
if err != nil {
63+
log.Debugf("error_check failed: %v", err)
64+
}
6365
}
6466
}
6567
}()

0 commit comments

Comments
 (0)