fix(api): shot API 500 once a version has a ProRes size
Deploy / deploy (push) Successful in 3m16s

Version.highResSize (added in 9660cdc) is a BigInt, and GET
/api/shots/[shotId] spreads whole version rows into NextResponse.json,
converting only fileSize. As soon as worker 1.7.0 finalized an export
with a ProRes upload, JSON.stringify threw "Do not know how to serialize
a BigInt" and the shot page failed to load.

- Convert highResSize alongside fileSize in that route.
- lib/db.ts: serialize any BigInt as a string in JSON (BigInt.prototype
  .toJSON), so other routes returning whole rows can't 500 the same way.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
twotalesanimation
2026-09-22 17:23:03 +02:00
parent 9660cdc21c
commit 27f9f7ac64
2 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -82,7 +82,7 @@ export async function GET(
session.user.role as string
);
// Serialize BigInt fields (fileSize) so JSON.stringify doesn't throw
// Serialize BigInt fields (fileSize, highResSize) so JSON.stringify doesn't throw
const shotSerialized = {
...shot,
footagePlates: shot.footagePlates.map((p) => ({
@@ -92,6 +92,7 @@ export async function GET(
versions: shot.versions.map((v) => ({
...v,
fileSize: v.fileSize != null ? v.fileSize.toString() : null,
highResSize: v.highResSize != null ? v.highResSize.toString() : null,
})),
};