diff --git a/.changeset/nasty-drinks-itch.md b/.changeset/nasty-drinks-itch.md new file mode 100644 index 00000000..450f373c --- /dev/null +++ b/.changeset/nasty-drinks-itch.md @@ -0,0 +1,5 @@ +--- +"@tus/s3-store": patch +--- + +Fix offset being returned as `NaN` when there are no S3 parts found diff --git a/packages/s3-store/src/index.ts b/packages/s3-store/src/index.ts index 5009c602..e371f317 100644 --- a/packages/s3-store/src/index.ts +++ b/packages/s3-store/src/index.ts @@ -56,8 +56,7 @@ export type MetadataValue = { } function calcOffsetFromParts(parts?: Array) { - // @ts-expect-error not undefined - return parts && parts.length > 0 ? parts.reduce((a, b) => a + b.Size, 0) : 0 + return parts && parts.length > 0 ? parts.reduce((a, b) => a + (b.Size ?? 0), 0) : 0 } // Implementation (based on https://github.com/tus/tusd/blob/master/s3store/s3store.go)