Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pkskpro committed Jan 15, 2025
2 parents bf3bef4 + f2d1ad8 commit 400a789
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 29 deletions.
16 changes: 9 additions & 7 deletions examples/grpc_server/go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
module go.k6.io/k6/examples/grpc_server

go 1.19
go 1.21

toolchain go1.21.13

replace go.k6.io/k6 => ../../

require (
go.k6.io/k6 v0.0.0-00010101000000-000000000000
google.golang.org/grpc v1.64.1
google.golang.org/grpc v1.67.1
)

require (
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/protobuf v1.35.1 // indirect
)
25 changes: 13 additions & 12 deletions examples/grpc_server/go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 h1:AgADTJarZTBqgjiUzRgfaBchgYB3/WFTC80GPwsMcRI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=
google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd h1:6TEm2ZxXoQmFWFlt1vNxvVOa1Q0dXFQD1m/rYjXmS0E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
2 changes: 1 addition & 1 deletion js/modules/k6/browser/common/element_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (h *ElementHandle) checkHitTargetAt(apiCtx context.Context, point Position)
return false, fmt.Errorf("checking hit target at %v: %w", point, err)
}
if frame != nil && frame.parentFrame != nil {
el, err := h.frame.FrameElement()
el, err := frame.FrameElement()
if err != nil {
return false, err
}
Expand Down
8 changes: 8 additions & 0 deletions js/modules/k6/browser/common/execution_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ func (e *ExecutionContext) adoptBackendNodeID(backendNodeID cdp.BackendNodeID) (
return nil, fmt.Errorf("resolving DOM node: %w", err)
}

// This can occur due to race conditions between trying to click on an element
// and chrome moving on (e.g. navigating).
if remoteObj == nil {
return nil, fmt.Errorf(`the page may have navigated away or the element is
now missing. It might happen when k6 and/or Chrome are overloaded. You
might need to increase the compute resources`)
}

return NewJSHandle(e.ctx, e.session, e, e.frame, remoteObj, e.logger).AsElement(), nil
}

Expand Down
8 changes: 4 additions & 4 deletions js/modules/k6/browser/common/frame_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ func (m *FrameManager) frameDetached(frameID cdp.FrameID, reason cdppage.FrameDe
// when the type of detach is a swap. After this detach event usually
// the iframe navigates, which requires the frames to be present for the
// navigate to work.
fs := m.page.getFrameSession(frameID)
if fs != nil {
fs, ok := m.page.getFrameSession(frameID)
if ok {
m.logger.Debugf("FrameManager:frameDetached:sessionFound",
"fmid:%d fid:%v fsID1:%v fsID2:%v found session for frame",
m.ID(), frameID, fs.session.ID(), m.session.ID())
Expand Down Expand Up @@ -657,8 +657,8 @@ func (m *FrameManager) NavigateFrame(frame *Frame, url string, parsedOpts *Frame
})
defer lifecycleEvtCancel()

fs := frame.page.getFrameSession(cdp.FrameID(frame.ID()))
if fs == nil {
fs, ok := frame.page.getFrameSession(cdp.FrameID(frame.ID()))
if !ok {
m.logger.Debugf("FrameManager:NavigateFrame",
"fmid:%d fid:%v furl:%s url:%s fs:nil",
fmid, fid, furl, url)
Expand Down
5 changes: 4 additions & 1 deletion js/modules/k6/browser/common/frame_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,10 @@ func (fs *FrameSession) attachIFrameToTarget(ti *target.Info, sid target.Session
return fmt.Errorf("attaching iframe target ID %v to session ID %v: %w",
ti.TargetID, sid, err)
}
fs.page.attachFrameSession(cdp.FrameID(ti.TargetID), nfs)

if err := fs.page.attachFrameSession(cdp.FrameID(ti.TargetID), nfs); err != nil {
return err
}

return nil
}
Expand Down
22 changes: 18 additions & 4 deletions js/modules/k6/browser/common/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,11 @@ func (p *Page) getFrameElement(f *Frame) (handle *ElementHandle, _ error) {
for ; rootFrame.parentFrame != nil; rootFrame = rootFrame.parentFrame {
}

parentSession := p.getFrameSession(cdp.FrameID(rootFrame.ID()))
parentSession, ok := p.getFrameSession(cdp.FrameID(rootFrame.ID()))
if !ok {
return nil, errors.New("parent frame has been detached")
}

action := dom.GetFrameOwner(cdp.FrameID(f.ID()))
backendNodeID, _, err := action.Do(cdp.WithExecutor(p.ctx, parentSession.session))
if err != nil {
Expand Down Expand Up @@ -678,18 +682,28 @@ func (p *Page) getOwnerFrame(apiCtx context.Context, h *ElementHandle) (cdp.Fram
return frameID, nil
}

func (p *Page) attachFrameSession(fid cdp.FrameID, fs *FrameSession) {
func (p *Page) attachFrameSession(fid cdp.FrameID, fs *FrameSession) error {
p.logger.Debugf("Page:attachFrameSession", "sid:%v fid=%v", p.session.ID(), fid)

if fs == nil {
return errors.New("internal error: FrameSession is nil")
}

p.frameSessionsMu.Lock()
defer p.frameSessionsMu.Unlock()
fs.page.frameSessions[fid] = fs

return nil
}

func (p *Page) getFrameSession(frameID cdp.FrameID) *FrameSession {
func (p *Page) getFrameSession(frameID cdp.FrameID) (*FrameSession, bool) {
p.logger.Debugf("Page:getFrameSession", "sid:%v fid:%v", p.sessionID(), frameID)
p.frameSessionsMu.RLock()
defer p.frameSessionsMu.RUnlock()
return p.frameSessions[frameID]

v, ok := p.frameSessions[frameID]

return v, ok
}

func (p *Page) hasRoutes() bool {
Expand Down

0 comments on commit 400a789

Please sign in to comment.