diff --git a/api/RequestHandler.md b/api/RequestHandler.md index ce97443b..7d7423cf 100644 --- a/api/RequestHandler.md +++ b/api/RequestHandler.md @@ -206,8 +206,8 @@ is the URL of the top-level frame. Cookies managers can be unique per browser or shared across multiple browsers. The global cookie manager will be used if this method returns None. -**IMPORTANT**: In some cases the `browser` parameter can be -None, so you should handle such case. +**IMPORTANT**: In some cases this callback is not called due to a +race condition. See Issue [#429](../../../issues/429) for details. To successfully implement separate cookie manager per browser session, you have to set ApplicationSettings.`unique_request_context_per_browser` diff --git a/docs/Migration-guide.md b/docs/Migration-guide.md index 32f301e1..3e419176 100644 --- a/docs/Migration-guide.md +++ b/docs/Migration-guide.md @@ -378,9 +378,9 @@ See a complete list of flags in the description of cef.Request.[GetFlags](../api/Request.md#getflags) method. -## v66+ RequestHandler.GetCookieManager 'browser' param may be None +## v66+ RequestHandler.GetCookieManager not getting called in some cases -In some cases in RequestHandler.[GetCookieManager](../api/RequestHandler.md#getcookiemanager) -callback, the `browser` parameter may be None due to a race condition. -See Issue [#429](../../../issues/429) for details. +In some cases the RequestHandler.[GetCookieManager](../api/RequestHandler.md#getcookiemanager) +callback is not getting called due to a race condition. +This bug is to be fixed in Issue [#429](../../../issues/429). diff --git a/src/handlers/request_handler.pyx b/src/handlers/request_handler.pyx index be50b8af..02bbc15d 100644 --- a/src/handlers/request_handler.pyx +++ b/src/handlers/request_handler.pyx @@ -291,14 +291,13 @@ cdef public CefRefPtr[CefCookieManager] RequestHandler_GetCookieManager( cdef object clientCallback cdef PyCookieManager returnValue try: - if cefBrowser.get(): - pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager") - else: - pyBrowser = None + if not cefBrowser.get(): + # Bug: In some cases due to a race condition the browser + # may be NULL. Issue #429. + return NULL + pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager") pyMainUrl = CefToPyString(cefMainUrl) - if pyBrowser: - # Browser may be empty. - clientCallback = pyBrowser.GetClientCallback("GetCookieManager") + clientCallback = pyBrowser.GetClientCallback("GetCookieManager") if clientCallback: returnValue = clientCallback( browser=pyBrowser,