Repository navigation
Migrate the keyed package-invocation idempotency ledger from D1 into the per-user RunLog DO #1053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a3b1b80
8eb2eb9
2416016
606057a
3f921ce
8dea512
8d03cf8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| import { ensureEmailTestSchema } from './test-schema.ts' | ||
| import { ensureUsageRollupsTestSchema } from '#worker/usage/test-schema.ts' | ||
| import { buildPublishedSourceManifestSnapshotKvKey } from '#worker/package-runtime/published-runtime-artifacts.ts' | ||
| import { exportRunRecords } from '#worker/run-records/service.ts' | ||
| import { silenceIncidentalRuntimeWarnings } from '#worker/test-support/incidental-runtime-warnings.ts' | ||
| import { createStableUserIdFromEmail } from '#worker/user-id.ts' | ||
|
|
||
|
|
@@ -310,7 +311,7 @@ | |
| }) | ||
| // A non-admin saving the identical subscription must never receive | ||
| // operator system mail. | ||
| const regularPackage = await seedSubscribedPackage({ | ||
| bundleKv, | ||
| userId: regularStableId, | ||
| scope: 'sysuser', | ||
|
|
@@ -369,23 +370,24 @@ | |
| expect(stored).toBeDefined() | ||
| if (!stored) throw new Error('Expected stored system message') | ||
|
|
||
| const invocations = await env.APP_DB.prepare( | ||
| `SELECT package_id, export_name, topic, source, idempotency_key, response_json | ||
| FROM package_invocations | ||
| WHERE package_id IN (?, ?)`, | ||
| ) | ||
| .bind(adminPackage.packageId, regularPackage.packageId) | ||
| .all<Record<string, unknown>>() | ||
| expect(invocations.results).toHaveLength(1) | ||
| const invocation = invocations.results?.[0] | ||
| // The keyed idempotency ledger lives in each owner's RunLog DO now. | ||
| const adminInvocations = ( | ||
| await exportRunRecords({ env, userId: adminStableId, pageSize: 100 }) | ||
| ).packageInvocations | ||
| const regularInvocations = ( | ||
| await exportRunRecords({ env, userId: regularStableId, pageSize: 100 }) | ||
| ).packageInvocations | ||
| expect(regularInvocations).toHaveLength(0) | ||
| expect(adminInvocations).toHaveLength(1) | ||
| const invocation = adminInvocations[0] | ||
| expect(invocation).toMatchObject({ | ||
| package_id: adminPackage.packageId, | ||
| export_name: `subscription:${systemTopic}`, | ||
| packageId: adminPackage.packageId, | ||
| exportName: `subscription:${systemTopic}`, | ||
| topic: systemTopic, | ||
| source: 'email', | ||
| idempotency_key: `email:${stored.id}:${adminPackage.packageId}:${systemTopic}`, | ||
| idempotencyKey: `email:${stored.id}:${adminPackage.packageId}:${systemTopic}`, | ||
| }) | ||
| const response = JSON.parse(String(invocation?.['response_json'])) as { | ||
| const response = JSON.parse(String(invocation?.responseJson)) as { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Nullable
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| body: Record<string, unknown> | ||
| } | ||
| expect(response.body).toMatchObject({ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.