-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(context): reload page for CDP remote browser connections #682
Conversation
Problem When using CDP (Chrome DevTools Protocol) connections, page operations were resulting in timeout errors after 30000ms. This specifically occurred during page load state verification: pythonCopyawait page.wait_for_load_state() The error manifests in the following call stack: context.py line 219 - Initial wait_for_load_state call Propagates through Playwright's async API Times out in frame implementation while waiting for load state Solution Implemented page reloading specifically for CDP connections to prevent these timeout errors. This addresses the underlying issue where the page load state was not being properly detected in CDP scenarios. Implementation Details Added conditional page reload for CDP connection types Maintains existing behavior for non-CDP connections Ensures proper page load state verification Testing Verified fix resolves timeout errors with CDP connections Confirmed existing functionality remains intact for other connection types Reference Solution approach based on discords support ticket - https://discord.com/channels/1303749220842340412/1334218695509016657/1334517519611990056
I opened a Pull Request with the following: 🔄 1 test added. 🔄 Test UpdatesI've added 1 tests. They all pass ☑️
No existing tests required updates. 🐛 Bug DetectionNo bugs detected in your changes. Good job! 🛠️ Test Results1/9 tests passed tests/test_dropdown.py View errortests/test_dropdown.py:20: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_dropdown_complex.py View errortests/test_dropdown_complex.py:20: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_dropdown_error.py View errortests/test_dropdown_error.py:20: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_gif_path.py View errortests/test_gif_path.py:19: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_models.py View errortests/test_models.py:54: in <module>
ChatOpenAI(
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_react_dropdown.py View errortests/test_react_dropdown.py:20: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_save_conversation.py View errortests/test_save_conversation.py:20: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_vision.py View errortests/test_vision.py:25: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
☂️ Coverage ImprovementsCoverage improvements by file:
🎨 Final Touches
Settings | Logs | CodeBeaver |
fix(context): reload page for CDP remote browser connections
Problem
When using CDP (Chrome DevTools Protocol) connections, page operations were resulting in timeout errors after 30000ms. This specifically occurred during page load state verification: await page.wait_for_load_state()
The error manifests in the following call stack:
context.py line 219 - Initial wait_for_load_state call Propagates through Playwright's async API
Times out in frame implementation while waiting for load state
Solution
Implemented page reloading specifically for CDP connections to prevent these timeout errors. This addresses the underlying issue where the page load state was not being properly detected in CDP scenarios.
Implementation Details
Added conditional page reload for CDP connection types Maintains existing behavior for non-CDP connections Ensures proper page load state verification
Testing
Verified fix resolves timeout errors with CDP connections Confirmed existing functionality remains intact for other connection types
Reference
Solution approach based on discord support ticket - https://discord.com/channels/1303749220842340412/1334218695509016657/1334517519611990056