Repository navigation
fix(agent-device): clean up screenshots after cancelled captures - #206
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Comment on lines
+607
to
+614
| return this.command('screenshot', async (client) => { | ||
| const directory = mkdtempSync(path.join(tmpdir(), 'e2e-agent-device-')); | ||
| const file = path.join(directory, 'screenshot.png'); | ||
| try { | ||
| const shot = await client.capture.screenshot({ path: file }); | ||
| return new Uint8Array(readFileSync(shot.path ?? file)); | ||
| } finally { | ||
| rmSync(directory, { recursive: true, force: true }); |
Contributor
There was a problem hiding this comment.
🟡 Final cancelled screenshot survives shutdown
When the final screenshot is cancelled, rawScreenshot can outlive disposal because worker shutdown never waits for tracked commands. The child worker exits before finally removes the temporary directory.
Prompt for agents
AgentDeviceSurface tracks cancelled screenshot work in inflight, but only startAttempt waits for that set. At worker shutdown, packages/agent-device/src/surface.ts dispose closes the session without waiting for inflight commands, and packages/e2e/src/run/worker/session.ts exits the child after dispose returns. A cancelled screenshot on the final attempt can therefore lose the rawScreenshot finally cleanup when the worker exits. Update disposal to give tracked commands a bounded chance to settle and clean their temporary directories before session closure and worker exit, while preserving cleanupTimeout behavior for commands that never settle. Add a regression covering cancellation followed directly by dispose rather than another startAttempt.
Was this helpful? React with 👍 or 👎 to provide feedback.
okwasniewski
force-pushed
the
fix/device-screenshot-cleanup
branch
from
September 8, 2026 17:48
65d2814 to
15ec617
Compare
This branch was successfully 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.
What and why
mainand verify cleanup before the next app launch.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). Not applicable.docs/src/content/docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. Not applicable.@e2edev/e2e/engine): changesets for@e2edev/e2e,@e2edev/playwright, and@e2edev/agent-device. Not applicable.