Skip to content

Conversation

@Murderlon
Copy link
Member

Closes #783

@Murderlon Murderlon self-assigned this Aug 19, 2025
@changeset-bot
Copy link

changeset-bot bot commented Aug 19, 2025

🦋 Changeset detected

Latest commit: 2cffb87

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tus/s3-store Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Aug 19, 2025

Walkthrough

Adds a changeset for @tus/s3-store and updates calcOffsetFromParts in packages/s3-store/src/index.ts to avoid NaN offsets by summing S3 part sizes with a nullish coalescing fallback.

Changes

Cohort / File(s) Summary
Release metadata
./.changeset/nasty-drinks-itch.md
Adds patch release note for @tus/s3-store: fix offset being NaN when no S3 parts are found.
S3 offset handling
packages/s3-store/src/index.ts
calcOffsetFromParts now uses (b.Size ?? 0) in reduce; removes ts-expect-error. No exported API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix NaN Upload-Offset in HEAD response when resuming uploads (#783)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Add patch changeset entry (.changeset/nasty-drinks-itch.md) Release metadata; not a functional change but acceptable accompanying change for the bug fix.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch s3-offset-NaN

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.changeset/nasty-drinks-itch.md (1)

1-5: Changeset text and bump scope look correct (patch).

Message is clear and scoped to the S3 store. Minor nit: consider ending the sentence with a period for consistency with typical changeset prose.

Apply this tiny edit if you want:

-Fix offset being returned as `NaN` when there are no S3 parts found
+Fix offset being returned as `NaN` when there are no S3 parts found.
packages/s3-store/src/index.ts (1)

58-60: Solid fix: avoids NaN when S3 vendor returns undefined Part.Size.

Using b.Size ?? 0 with an initial accumulator of 0 closes the NaN hole and is safe for empty parts. You can simplify slightly by dropping the explicit length check.

Optionally, simplify and keep the guard explicit:

-function calcOffsetFromParts(parts?: Array<AWS.Part>) {
-  return parts && parts.length > 0 ? parts.reduce((a, b) => a + (b.Size ?? 0), 0) : 0
-}
+function calcOffsetFromParts(parts?: Array<AWS.Part>) {
+  const arr = parts ?? []
+  return arr.reduce((sum, p) => sum + (typeof p.Size === 'number' ? p.Size : 0), 0)
+}

If you’d like, I can add a regression test that stubs listParts to return a Part with Size: undefined and asserts getUpload(id).offset is numeric (0) rather than NaN.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 688a578 and 2cffb87.

📒 Files selected for processing (2)
  • .changeset/nasty-drinks-itch.md (1 hunks)
  • packages/s3-store/src/index.ts (1 hunks)

@Murderlon Murderlon merged commit 011ac76 into main Aug 19, 2025
4 checks passed
@Murderlon Murderlon deleted the s3-offset-NaN branch August 19, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NaN Upload-offset in Tus-server response

2 participants