Handle storage URL resolution failures gracefully

- Batch storage URL lookups to reduce request spikes
- Log and skip failed URL resolutions instead of throwing
- Preserve node reads when attached storage is unavailable
This commit is contained in:
Matthias
2026-04-01 20:41:05 +02:00
parent 3926940c5a
commit 2142249ed5
2 changed files with 67 additions and 15 deletions

View File

@@ -126,17 +126,27 @@ export const get = query({
return null;
}
const data = node.data as Record<string, unknown> | undefined;
if (!data?.storageId) {
return node;
}
const data = node.data as Record<string, unknown> | undefined;
if (!data?.storageId) {
return node;
}
const url = await ctx.storage.getUrl(data.storageId as Id<"_storage">);
let url: string | null;
try {
url = await ctx.storage.getUrl(data.storageId as Id<"_storage">);
} catch (error) {
console.warn("[nodes.get] failed to resolve storage URL", {
nodeId: node._id,
storageId: data.storageId,
error: String(error),
});
return node;
}
return {
...node,
data: {
...data,
return {
...node,
data: {
...data,
url: url ?? undefined,
},
};