Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@cloudflare/workers-oauth-provider": "1.2.4",
"@hono/node-server": "1.19.9",
"@hono/valibot-validator": "0.6.1",
"@mastra/core": "1.81.0",
"@mastra/core": "1.83.0",
"@modelcontextprotocol/server": "2.3.1",
"@simple-agent-manager/agent-email": "workspace:*",
"@simple-agent-manager/ai-proxy": "workspace:*",
Expand Down
13 changes: 12 additions & 1 deletion apps/api/tests/integration/runtime-secret-requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,12 +754,17 @@ describe('hardening', () => {
const firstHeld = new Promise<void>((resolve) => {
releaseFirst = resolve;
});
let firstBatchEntered!: () => void;
const firstAtBatch = new Promise<void>((resolve) => {
firstBatchEntered = resolve;
});
let batches = 0;
let firstRan: Promise<unknown> = Promise.resolve();
env.DATABASE.batch = (async (statements: D1PreparedStatement[]) => {
batches += 1;
if (batches === 1) {
firstRan = firstHeld.then(() => realBatch(statements));
firstBatchEntered();
return firstRan;
}
// Second submit: both have now passed every pre-check. Run the first transaction, then this.
Expand All @@ -768,8 +773,14 @@ describe('hardening', () => {
return realBatch(statements);
}) as typeof env.DATABASE.batch;

const firstSubmit = fulfill(request.id, { value: SENTINEL });
// Async encryption can reorder batch arrival. Hold the first request at its
// transaction before starting the second, while both still read pending.
await firstAtBatch;
expect(requestRow(request.id)?.status).toBe('pending');
expect(envRow('STRIPE_API_KEY')).toBeUndefined();
const [first, second] = await Promise.all([
fulfill(request.id, { value: SENTINEL }),
firstSubmit,
fulfill(request.id, { value: OTHER_SENTINEL }),
]);
expect(batches).toBe(2);
Expand Down
Loading
Loading