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

Commit 168be19

Browse files
committed
Fix possible race by unlocking mutex earlier
This is unlikely but we should give up the mutex early just in case we use it where ever EventFrameNavigation event is consumed. Resolves: #630 (comment)
1 parent 8253ddb commit 168be19

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

common/frame_manager.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,13 @@ func (m *FrameManager) frameAbortedNavigation(frameID cdp.FrameID, errorText, do
122122
}
123123

124124
frame.pendingDocumentMu.Lock()
125-
defer frame.pendingDocumentMu.Unlock()
126125

127126
if frame.pendingDocument == nil {
127+
frame.pendingDocumentMu.Unlock()
128128
return
129129
}
130130
if documentID != "" && frame.pendingDocument.documentID != documentID {
131+
frame.pendingDocumentMu.Unlock()
131132
return
132133
}
133134

@@ -142,6 +143,9 @@ func (m *FrameManager) frameAbortedNavigation(frameID cdp.FrameID, errorText, do
142143
err: errors.New(errorText),
143144
}
144145
frame.pendingDocument = nil
146+
147+
frame.pendingDocumentMu.Unlock()
148+
145149
frame.emit(EventFrameNavigation, ne)
146150
}
147151

0 commit comments

Comments
 (0)