[refactor]: add locator operation context - #3013
Open
seanmcguire12 wants to merge 4 commits into
Open
seanmcguire12 wants to merge 4 commits into
seanmcguire12 wants to merge 4 commits into
Conversation
seanmcguire12
added this pull request to stack #3014
September 22, 2026 23:53
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Architecture diagram
sequenceDiagram
participant Caller as Locator Caller
participant Op as LocatorOperation
participant Timer as Timer System
participant Work as Work Function
participant Cleanup as Cleanup Function
participant Error as TimeoutError
Note over Caller,Error: ONE shared timeout budget for the whole locator call
Caller->>Op: runLocatorOperation({name, timeout}, work)
alt New operation
Op->>Op: Validate timeout (finite, >= 0)
Op->>Timer: scheduleDeadline()
else Existing operation
Note over Op: Reuse parent deadline, no new timer
end
Op->>Op: run(name, delegate to work)
Op->>Op: throwIfStopped() - check clock + abort signal
Op->>Work: Execute step (frame check, element lookup, action)
loop Each nested step
Work->>Op: run(phase, stepWork, onLateResult?)
Op->>Op: throwIfStopped() before dispatch
alt Work completes before deadline
Op-->>Work: Return result
else Deadline expires during work
Op->>Timer: Deadline timer fires
Op->>Op: expireIfNeeded() - abort signal
Op->>Error: Create TimeoutError "while {phase}"
Op-->>Work: Abort step
end
end
alt Result crossed deadline
Op->>Cleanup: onLateResult(value)
Cleanup->>Op: release() with 1s cap
Op-->>Cleanup: Swallow cleanup errors
end
opt Multiple timer intervals needed
loop Remaining > MAX_TIMER_MS
Op->>Timer: setTimeout(MAX_TIMER_MS)
Timer-->>Op: scheduleDeadline() again
end
end
Op-->>Caller: Final result or TimeoutError
Note over Op,Cleanup: Concurrent calls stay independent
Caller->>Op: Another runLocatorOperation()
Op->>Op: Separate AbortController + deadline
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
seanmcguire12
force-pushed
the
add-locator-operation-context
branch
from
September 23, 2026 18:24
02c654b to
c18ef88
Compare
seanmcguire12
removed this pull request from stack #3014
September 23, 2026 19:17
Base automatically changed from
evals/trippyogi-fix-iframe-main-world-loading
to
main
September 23, 2026 21:00
seanmcguire12
force-pushed
the
add-locator-operation-context
branch
from
September 23, 2026 21:08
c18ef88 to
e01fbc2
Compare
seanmcguire12
added this pull request to stack #3025
September 23, 2026 21:12
seanmcguire12
force-pushed
the
add-locator-operation-context
branch
from
September 25, 2026 22:05
e01fbc2 to
1d16972
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
why
a
locatoraction needs one timeout covering all of its downstream code (eg, checking frame readiness, finding the element, & taking the action). if setup uses three seconds of a five-second timeout, the action should have two seconds leftthis pr adds the shared timeout helper. later PRs will connect it to locator methods & add public timeout options.
what changed
locatorOperation.tsto track the time remaining for one call.runLocatorOperation()creates it once & all nested steps share it0disables the timeoutrun()to check the deadline before starting a step & stop waiting when time runs out. the error names the operation & the step that was still waiting.delay()so pauses between steps use the same timeout.cleanup()to attempt cleanup after a timeout, with a one-second limit on waiting. cleanup errors do not replace the original error.test plan
added tests in
locatorOperation.test.tsthat control time & hold responses opento verify:
Summary by cubic
Adds a shared locator operation context so a single timeout spans all steps of a locator action (frame checks, element lookup, and the action itself), replacing separate per-step deadlines.
runLocatorOperation()creates the context once and nested steps share its remaining budget; passing0disables the timeout.run()checks the deadline before each step,delay()pauses within the same budget, and cleanup of late resources is attempted for one second after expiry.Written for commit 1d16972. Summary will update on new commits.