diff --git a/src/browser/sync/local_state.ts b/src/browser/sync/local_state.ts index 0d9ce66..83a432b 100644 --- a/src/browser/sync/local_state.ts +++ b/src/browser/sync/local_state.ts @@ -24,6 +24,7 @@ type LocalQuery = { args: Record; numSubscribers: number; journal?: QueryJournal; + componentPath?: string; }; export class LocalSyncState { @@ -95,6 +96,7 @@ export class LocalSyncState { args, numSubscribers: 1, journal, + componentPath, }; this.querySet.set(queryToken, query); this.queryIdToToken.set(queryId, queryToken); @@ -279,6 +281,7 @@ export class LocalSyncState { udfPath: localQuery.canonicalizedUdfPath, args: [convexToJson(localQuery.args)], journal: localQuery.journal, + componentPath: localQuery.componentPath, }; modifications.push(add); diff --git a/src/bundler/context.ts b/src/bundler/context.ts index 86d9512..e92c521 100644 --- a/src/bundler/context.ts +++ b/src/bundler/context.ts @@ -16,7 +16,10 @@ export type ErrorType = // The `convex dev` command will wait for either file OR table data change // to retry (if a table name is specified as the value in this Object). | { - "invalid filesystem or db data": string | null; + "invalid filesystem or db data": { + tableName: string; + componentPath?: string; + } | null; } // The error was caused by either the local state (ie schema.ts content) // or the state of the deployment environment variables. diff --git a/src/cli/convexExport.ts b/src/cli/convexExport.ts index 0ad3868..f612ba3 100644 --- a/src/cli/convexExport.ts +++ b/src/cli/convexExport.ts @@ -145,6 +145,7 @@ async function waitForStableExportState( adminKey, "_system/cli/exports:getLatest", {}, + undefined, donePromise, { onChange: (value: any) => { diff --git a/src/cli/convexImport.ts b/src/cli/convexImport.ts index ed51ed0..bab2ae4 100644 --- a/src/cli/convexImport.ts +++ b/src/cli/convexImport.ts @@ -363,6 +363,7 @@ export async function waitForStableImportState( adminKey, "_system/cli/queryImport", { importId }, + undefined, donePromise, { onChange: (value: any) => { diff --git a/src/cli/dev.ts b/src/cli/dev.ts index b217fed..4da26e5 100644 --- a/src/cli/dev.ts +++ b/src/cli/dev.ts @@ -306,7 +306,12 @@ export async function watchAndPush( return; } const fileSystemWatch = getFileSystemWatch(ctx, watch, cmdOptions); - const tableWatch = getTableWatch(ctx, options, tableNameTriggeringRetry); + const tableWatch = getTableWatch( + ctx, + options, + tableNameTriggeringRetry?.tableName ?? null, + tableNameTriggeringRetry?.componentPath, + ); const envVarWatch = getDeplymentEnvVarWatch( ctx, options, @@ -330,9 +335,14 @@ function getTableWatch( adminKey: string; }, tableName: string | null, + componentPath: string | undefined, ) { - return getFunctionWatch(ctx, credentials, "_system/cli/queryTable", () => - tableName !== null ? { tableName } : null, + return getFunctionWatch( + ctx, + credentials, + "_system/cli/queryTable", + () => (tableName !== null ? { tableName } : null), + componentPath, ); } @@ -349,6 +359,7 @@ function getDeplymentEnvVarWatch( credentials, "_system/cli/queryEnvironmentVariables", () => (shouldRetryOnDeploymentEnvVarChange ? {} : null), + undefined, ); } @@ -360,6 +371,7 @@ function getFunctionWatch( }, functionName: string, getArgs: () => Record | null, + componentPath: string | undefined, ) { const [stopPromise, stop] = waitUntilCalled(); return { @@ -375,6 +387,7 @@ function getFunctionWatch( credentials.adminKey, functionName, args, + componentPath, stopPromise, { onChange: () => { diff --git a/src/cli/lib/deploy2.ts b/src/cli/lib/deploy2.ts index 21f79f2..193fcb3 100644 --- a/src/cli/lib/deploy2.ts +++ b/src/cli/lib/deploy2.ts @@ -154,7 +154,12 @@ export async function waitForSchema( return await ctx.crash({ exitCode: 1, errorType: { - "invalid filesystem or db data": currentStatus.tableName ?? null, + "invalid filesystem or db data": currentStatus.tableName + ? { + tableName: currentStatus.tableName, + componentPath: currentStatus.componentPath, + } + : null, }, printedMessage: null, // TODO - move logging into here }); diff --git a/src/cli/lib/indexes.ts b/src/cli/lib/indexes.ts index 0f43b9f..0201dba 100644 --- a/src/cli/lib/indexes.ts +++ b/src/cli/lib/indexes.ts @@ -133,7 +133,11 @@ async function waitForReadySchema( return await ctx.crash({ exitCode: 1, errorType: { - "invalid filesystem or db data": data.schemaState.tableName ?? null, + "invalid filesystem or db data": data.schemaState.tableName + ? { + tableName: data.schemaState.tableName, + } + : null, }, printedMessage: null, // TODO - move logging into here }); diff --git a/src/cli/lib/run.ts b/src/cli/lib/run.ts index 6f20757..0fe3683 100644 --- a/src/cli/lib/run.ts +++ b/src/cli/lib/run.ts @@ -125,6 +125,7 @@ export async function subscribeAndLog( adminKey: string, functionName: string, args: Record, + componentPath: string | undefined, ) { return subscribe( ctx, @@ -132,6 +133,7 @@ export async function subscribeAndLog( adminKey, functionName, args, + componentPath, waitForever(), { onStart() { @@ -156,6 +158,7 @@ export async function subscribe( adminKey: string, functionName: string, args: Record, + componentPath: string | undefined, until: Promise, callbacks?: { onStart?: () => void; @@ -177,7 +180,9 @@ export async function subscribe( }, ); client.setAdminAuth(adminKey); - const { unsubscribe } = client.subscribe(functionName, args); + const { unsubscribe } = client.subscribe(functionName, args, { + componentPath, + }); callbacks?.onStart?.(); diff --git a/src/cli/run.ts b/src/cli/run.ts index 10aee60..5779b5b 100644 --- a/src/cli/run.ts +++ b/src/cli/run.ts @@ -103,6 +103,7 @@ export const run = new Command("run") adminKey, functionName, args, + options.componentPath, ); } return await runFunctionAndLog(