fix: handle missing message in assistant generation telemetry
getGenerationTelemetry threw NOT_FOUND when the stored message id did not match a persisted message (e.g. the assistant message is still streaming or was just removed), surfacing as a failed tRPC query in the console. Return an empty complete result instead, matching the existing graceful handling for providers without OpenRouter telemetry, and only fire the client query once both threadId and messageId are available.
This commit is contained in:
2 files changed
+2
-2
No files matched your search
@@ -930,7 +930,7 @@ const RequestTelemetry = () => {
|
||||
const generationQuery = clientApi.assistant.getGenerationTelemetry.useQuery(
|
||||
{ threadId: threadId ?? "", messageId },
|
||||
{
|
||||
enabled: opened && persistedTelemetry?.provider === "openrouter" && Boolean(threadId),
|
||||
enabled: opened && persistedTelemetry?.provider === "openrouter" && Boolean(threadId) && Boolean(messageId),
|
||||
refetchInterval: (query) =>
|
||||
query.state.data?.complete === false && query.state.dataUpdateCount < 6 ? 1500 : false,
|
||||
retry: 2,
|
||||
|
||||
@@ -738,7 +738,7 @@ export const assistantRouter = createTRPCRouter({
|
||||
}),
|
||||
getConfigurationAsync(ctx.db),
|
||||
]);
|
||||
if (!message) throw new TRPCError({ code: "NOT_FOUND", message: "Message not found." });
|
||||
if (!message) return { complete: true, generations: [] };
|
||||
if (configuration?.provider !== "openrouter" || !configuration.encryptedApiKey) {
|
||||
return { complete: true, generations: [] };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user