Skip to content

Commit

Permalink
Explicitly check if we actually timed out
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov authored and ankur22 committed Jan 3, 2025
1 parent 3b15ea0 commit 381c5ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 11 additions & 1 deletion js/modules/k6/browser/common/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,22 @@ func (b *Browser) newPageInContext(id cdp.BrowserContextID) (*Page, error) {
page = b.pages[tid]
b.pagesMu.RUnlock()
case <-ctx.Done():
b.logger.Debugf("Browser:newPageInContext:<-ctx.Done", "tid:%v bctxid:%v err:%v", tid, id, ctx.Err())
}

if err = ctx.Err(); err != nil {
err = &k6ext.UserFriendlyError{
Err: ctx.Err(),
Timeout: b.browserOpts.Timeout,
}
b.logger.Debugf("Browser:newPageInContext:<-ctx.Done", "tid:%v bctxid:%v err:%v", tid, id, err)
}

if err == nil && page == nil {
err = &k6ext.UserFriendlyError{
Err: errors.New("can't fetch the page for unknown reason"),
}
}

return page, err
}

Expand Down
4 changes: 1 addition & 3 deletions js/modules/k6/browser/common/browser_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ func (b *BrowserContext) NewPage() (*Page, error) {
if b != nil {
bctxid = b.id
}
if p != nil {
ptid = p.targetID
}

b.logger.Debugf("BrowserContext:NewPage:return", "bctxid:%v ptid:%s", bctxid, ptid)

return p, nil
Expand Down

0 comments on commit 381c5ae

Please sign in to comment.