Skip to content

Automate browser based workflows with AI

Scope the scraper sleep recorder so a foreign sleeper cannot corrupt its assertions (#8313)

Aaron Perez861aa40f38c1
diff --git a/skyvern-frontend/src/routes/workflows/editor/WorkflowInputs.tsx b/skyvern-frontend/src/routes/workflows/editor/WorkflowInputs.tsx
index 7a90bc0ce..3c6e4b49f 100644
--- a/skyvern-frontend/src/routes/workflows/editor/WorkflowInputs.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/WorkflowInputs.tsx
@@ -66,7 +66,13 @@ function WorkflowInputsCard({ editable }: { editable: boolean }) {
}
return (
- <div className="nodrag nopan w-[30rem] rounded-lg bg-slate-elevation3 px-6 py-4">
+ // The card sits inside the start node, whose canvas click selects it and
+ // expands Workflow Settings (FlowRenderer's onNodeClick). This summary is
+ // its own surface, so no click in it reaches that.
+ <div
+ className="nodrag nopan w-[30rem] rounded-lg bg-slate-elevation3 px-6 py-4"
+ onClick={(event) => event.stopPropagation()}
+ >
<div className="flex items-center justify-between gap-3">
<span className="flex items-center gap-2 text-sm">
<InputIcon className="size-4 text-muted-foreground" aria-hidden />
@@ -77,13 +83,9 @@ function WorkflowInputsCard({ editable }: { editable: boolean }) {
variant="tertiary"
size="sm"
disabled={isRecording}
- // A click that reaches the node selects the start node and
- // dispatches OPEN_WORKFLOW_SETTINGS_EVENT (FlowRenderer's
- // onNodeClick), so Add would also expand Workflow Settings.
- onClick={(event) => {
- event.stopPropagation();
- setWorkflowPanelState({ active: true, content: "parameters" });
- }}
+ onClick={() =>
+ setWorkflowPanelState({ active: true, content: "parameters" })
+ }
>
<PlusIcon className="mr-1 size-3.5" aria-hidden />
Add
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/StartNode/StartNode.test.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/StartNode/StartNode.test.tsx
index ac153d482..7f14e4bf9 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/StartNode/StartNode.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/StartNode/StartNode.test.tsx
@@ -157,9 +157,19 @@ describe("StartNode inputs summary", () => {
expect(screen.queryByRole("button", { name: /add/i })).toBeNull();
});
- test("Add does not also open workflow settings", () => {
- // The click bubbles to FlowRenderer's onNodeClick, which dispatches
- // OPEN_WORKFLOW_SETTINGS_EVENT for the root start node.
+ test("no click on the card opens workflow settings", () => {
+ // Any click reaching the node runs FlowRenderer's onNodeClick, which
+ // dispatches OPEN_WORKFLOW_SETTINGS_EVENT for the root start node.
+ useWorkflowParametersStore.setState({
+ parameters: [
+ {
+ key: "order_id",
+ parameterType: "workflow",
+ dataType: "string",
+ defaultValue: null,
+ },
+ ],
+ });
const onNodeClick = vi.fn();
render(
<MemoryRouter initialEntries={["/workflows/wpid_abc/studio"]}>
@@ -169,6 +179,8 @@ describe("StartNode inputs summary", () => {
</MemoryRouter>,
);
+ fireEvent.click(screen.getByText("Inputs"));
+ fireEvent.click(screen.getByText("order_id"));
fireEvent.click(screen.getByRole("button", { name: /add/i }));
expect(onNodeClick).not.toHaveBeenCalled();
diff --git a/tests/unit/test_scraper_engine_timeout_classification.py b/tests/unit/test_scraper_engine_timeout_classification.py
index 963d6aaec..e543d57c2 100644
--- a/tests/unit/test_scraper_engine_timeout_classification.py
+++ b/tests/unit/test_scraper_engine_timeout_classification.py
@@ -9,6 +9,7 @@ hold on an image shipping only stock Playwright.
from __future__ import annotations
+import asyncio
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock, call, patch
@@ -64,6 +65,20 @@ async def _run_scrape_and_capture(browser_state: SimpleNamespace, error: BaseExc
return exc_info.value
+class _ScraperAsyncio:
+ """Stands in for ``scraper``'s own ``asyncio`` binding so only its sleeps are recorded.
+
+ ``setattr(scraper.asyncio, "sleep", ...)`` mutates the one process-global asyncio module,
+ so any coroutine sleeping on another thread lands in the same recorder.
+ """
+
+ def __init__(self, sleep: AsyncMock) -> None:
+ self.sleep = sleep
+
+ def __getattr__(self, name: str) -> object:
+ return getattr(asyncio, name)
+
+
def _scraped_page() -> ScrapedPage:
return ScrapedPage(
elements=[],
@@ -95,7 +110,7 @@ class TestScrapeWebsiteEmptyTreeRecovery:
sleep = AsyncMock()
log = MagicMock()
monkeypatch.setattr(scraper, "scrape_web_unsafe", scrape_web_unsafe)
- monkeypatch.setattr(scraper.asyncio, "sleep", sleep)
+ monkeypatch.setattr(scraper, "asyncio", _ScraperAsyncio(sleep))
monkeypatch.setattr(scraper, "LOG", log)
unsafe_kwargs = {