fix(workspaces): await getAgentByName so deletion actually purges storage#675
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(workspaces): await getAgentByName so deletion actually purges storage#675posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
getAgentByName became async in the agents 0.18.0 upgrade (commit 7e57970). The lifecycle helpers in durable-object-lifecycle.ts called it without await and hid the Promise behind `as unknown as` casts, so callers invoked purgeForDeletion()/mergeLinkedAnonymousUser() on a Promise. That threw on every invocation of the workspace/account deletion resource-purge path; the error was caught and logged as an operational failure, so deletions appeared to succeed while Durable Object storage and R2 files were never purged. Make the two lifecycle helpers async and await getAgentByName before returning, await them at their call sites, and fix the same missing await in user-ai-agents.ts. The DO namespaces are typed as DurableObjectNamespace<Agent>, so the awaited stub is directly assignable to the narrow interfaces — dropping the `as unknown as` casts lets TypeScript catch this class of missing-await bug going forward. Generated-By: PostHog Code Task-Id: 9758fa8c-b4ad-444a-a67c-37ef58c46fc8
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
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.
Summary
The
agents0.18.0 upgrade (commit7e579707) madegetAgentByNameasync — it now returns a Promise. The workspace/account deletion lifecycle helpers called it withoutawaitand papered over the type withas unknown as, so callers ended up invoking.purgeForDeletion()/.mergeLinkedAnonymousUser()on a Promise. That threw on every invocation of the resource-purge path. The error was caught and recorded as an operational failure rather than crashing the request, so deletions appeared to succeed while the backing Durable Object storage and R2 files were never purged — leaving orphaned data, storage cost, and a data-retention problem.This restores the awaited usage that
ai/auth.tsandkernel/workspace-kernel-auth.tsalready use correctly.Changes
getUserAIStoreLifecycleAgent/getWorkspaceKernelLifecycleAgentasyncandawait getAgentByName(...), thenawaitthem at their call sites.awaitinai/user-ai-agents.ts(mergeLinkedAnonymousUser).as unknown ascasts that hid the Promise type. The DO namespaces are typed asDurableObjectNamespace<Agent>, so the awaited stub is directly assignable to the narrow lifecycle interfaces — TypeScript now catches this class of missing-awaitbug.Why
Every workspace and account deletion silently failed to purge its backing storage after the 0.18.0 upgrade, and the failure was swallowed as a logged operational event — making it a quiet data-retention / orphaned-storage regression.
Test plan
tsc --noEmitpasses with no casts (confirms the awaited stub is assignable to the interfaces, so a future missingawaitwould fail to compile).vp lintclean on the changed files.Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.