Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 00eb584

Browse files
committed
Fix possible NPD
It doesn't make sense for this operation to continue when the frame is not present, so return early. If the frame is present continue as normal.
1 parent bbd616e commit 00eb584

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

common/frame_session.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -663,18 +663,25 @@ func (fs *FrameSession) onExecutionContextCreated(event *cdpruntime.EventExecuti
663663
if err := json.Unmarshal(auxData, &i); err != nil {
664664
k6ext.Panic(fs.ctx, "unmarshaling executionContextCreated event JSON: %w", err)
665665
}
666-
var world executionWorld
666+
667667
frame, ok := fs.manager.getFrameByID(i.FrameID)
668-
if ok {
669-
if i.IsDefault {
670-
world = mainWorld
671-
} else if event.Context.Name == utilityWorldName && !frame.hasContext(utilityWorld) {
672-
// In case of multiple sessions to the same target, there's a race between
673-
// connections so we might end up creating multiple isolated worlds.
674-
// We can use either.
675-
world = utilityWorld
676-
}
668+
if !ok {
669+
fs.logger.Debugf("FrameSession:onExecutionContextCreated:return",
670+
"sid:%v tid:%v ectxid:%d missing frame",
671+
fs.session.ID(), fs.targetID, event.Context.ID)
672+
return
677673
}
674+
675+
var world executionWorld
676+
if i.IsDefault {
677+
world = mainWorld
678+
} else if event.Context.Name == utilityWorldName && !frame.hasContext(utilityWorld) {
679+
// In case of multiple sessions to the same target, there's a race between
680+
// connections so we might end up creating multiple isolated worlds.
681+
// We can use either.
682+
world = utilityWorld
683+
}
684+
678685
if i.Type == "isolated" {
679686
fs.isolatedWorlds[event.Context.Name] = true
680687
}

0 commit comments

Comments
 (0)