Repository navigation
Conversation
Emulates the 1.0/storageStore and 1.0/storageGet async syscalls that convex 1.47 mutations use for ctx.storage.store/get. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="index.ts">
<violation number="1" location="index.ts:1828">
P2: `db.storeFile` mutates the committed file map before the surrounding mutation commits, so a later mutation error rolls back only `_storage` metadata and leaves the Blob retained. Stage file writes with the transaction and apply or discard them during commit/rollback to avoid leaking every file from a failed mutation.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| ...(type !== undefined ? { contentType: type } : {}), | ||
| }); | ||
| }); | ||
| db.storeFile(storageId, file); |
There was a problem hiding this comment.
P2: db.storeFile mutates the committed file map before the surrounding mutation commits, so a later mutation error rolls back only _storage metadata and leaves the Blob retained. Stage file writes with the transaction and apply or discard them during commit/rollback to avoid leaking every file from a failed mutation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At index.ts, line 1828:
<comment>`db.storeFile` mutates the committed file map before the surrounding mutation commits, so a later mutation error rolls back only `_storage` metadata and leaves the Blob retained. Stage file writes with the transaction and apply or discard them during commit/rollback to avoid leaking every file from a failed mutation.</comment>
<file context>
@@ -1807,6 +1807,39 @@ function asyncSyscallImpl() {
+ ...(type !== undefined ? { contentType: type } : {}),
+ });
+ });
+ db.storeFile(storageId, file);
+ return JSON.stringify(convexToJson(storageId));
+ }
</file context>
reeceyang
marked this pull request as draft
October 15, 2026 22:39
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.
Starting in convex 1.47, mutations can call
ctx.storage.store(blob)andctx.storage.get(id), which go through the new1.0/storageStoreand1.0/storageGetasync syscalls. convex-test throwsdoes not support async syscallon these. This PR emulates them, following the backend implementation incrates/isolate/src/environment/udf/async_syscall.rs:1.0/storageStorebase64-decodes the blob, computes its sha256, and rejects withSha256 mismatch. Expected: … Actual: …when the caller'ssha256option doesn't match. It then inserts a_storagedocument withsize,sha256, andcontentType(left out when the blob has no type). The insert goes through the mutation's transaction, so a mutation that throws also rolls back the file.1.0/storageGetreturns{ blob: <base64>, contentType }, ornullwhen the file is missing or was deleted. A file stored earlier in the same mutation can be read back.Per-transaction file read/write limits (
TooManyFilesWritten,FilesReadTooLarge, …) aren't emulated, because convex-test's metrics tracker doesn't track file storage yet.Bumps the
convexdevDependency to 1.47.0 so the tests use the new client code. The peer dependency stays at^1.43.0.npm run buildpasses (lint, typecheck, all tests).🤖 Generated with Claude Code