fix: audio attachments cannot be seeked using the progress slider - #41588
Conversation
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 2e9baee The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
📜 Recent review details⏰ Context from checks skipped due to timeout. (4)
|
| Layer / File(s) | Summary |
|---|---|
Range parsing and response headers apps/meteor/server/lib/media/file-upload/lib/ranges.ts, apps/meteor/server/lib/media/file-upload/config/FileSystem.ts, apps/meteor/server/lib/media/file-upload/config/GridFS.ts |
Range parsing supports omitted bounds and suffix ranges. getFileRange handles clamping and out-of-range cases. Upload responses set Accept-Ranges: bytes. |
Range behavior validation apps/meteor/server/lib/media/file-upload/lib/ranges.spec.ts, .changeset/lucky-donkeys-listen.md |
Tests cover valid, malformed, empty, clamped, suffix, final-byte, and out-of-range requests. A patch changeset documents the audio attachment seeking fix. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Possibly related PRs
- RocketChat/Rocket.Chat#41575: Updates another file-serving handler to advertise byte-range support.
Suggested labels: type: bug
Suggested reviewers: kevlehman
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly describes the main fix: enabling audio attachment seeking with the progress slider. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
- Fix failing CI checks
Warning
Review ran into problems
🔥 Problems
Errors were encountered while retrieving linked issues.
Errors (1)
- CORE-2477: Request failed with status code 401
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.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/meteor/server/lib/media/file-upload/lib/ranges.ts (1)
11-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the new implementation comments.
The branches are self-explanatory and the repository guideline prohibits implementation comments. As per coding guidelines, “Avoid code comments in the implementation.”
Also applies to: 40-40
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/meteor/server/lib/media/file-upload/lib/ranges.ts` at line 11, Remove the implementation comments describing omitted range bounds from the range parsing branches, including both locations identified by the review. Leave the range-handling logic unchanged.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/meteor/server/lib/media/file-upload/lib/ranges.spec.ts`:
- Around line 51-54: Extend the “flags a start at or beyond EOF as out of range”
test in getFileRange coverage with a bytes=200-100 request, and assert it
returns { outOfRange: true, start: 200, stop: 100 } to exercise the inverted
closed-range rejection path.
In `@apps/meteor/server/lib/media/file-upload/lib/ranges.ts`:
- Line 67: Ensure every file response advertises range support by setting
Accept-Ranges to bytes during general response initialization, rather than only
inside setRangeHeaders for valid Range requests. Update the relevant request
handling and add coverage for a request without a Range header, while preserving
existing range behavior.
---
Nitpick comments:
In `@apps/meteor/server/lib/media/file-upload/lib/ranges.ts`:
- Line 11: Remove the implementation comments describing omitted range bounds
from the range parsing branches, including both locations identified by the
review. Leave the range-handling logic unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d1d6dc6f-fa34-4efb-ab00-09e7aff2f5e8
📒 Files selected for processing (2)
apps/meteor/server/lib/media/file-upload/lib/ranges.spec.tsapps/meteor/server/lib/media/file-upload/lib/ranges.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
- GitHub Check: 📦 Build Packages
- GitHub Check: cubic · AI code reviewer
- GitHub Check: CodeQL-Build
- GitHub Check: Hacktron Security Check
- GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (1)
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ❌ **Has milestone or project** — This PR is missing the required milestone or project
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/server/lib/media/file-upload/lib/ranges.spec.tsapps/meteor/server/lib/media/file-upload/lib/ranges.ts
**/*.spec.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use.spec.tsextension for test files (e.g.,login.spec.ts)
Files:
apps/meteor/server/lib/media/file-upload/lib/ranges.spec.ts
🧠 Learnings (5)
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.
Applied to files:
apps/meteor/server/lib/media/file-upload/lib/ranges.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
apps/meteor/server/lib/media/file-upload/lib/ranges.spec.tsapps/meteor/server/lib/media/file-upload/lib/ranges.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
apps/meteor/server/lib/media/file-upload/lib/ranges.spec.tsapps/meteor/server/lib/media/file-upload/lib/ranges.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.
Applied to files:
apps/meteor/server/lib/media/file-upload/lib/ranges.spec.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
apps/meteor/server/lib/media/file-upload/lib/ranges.spec.tsapps/meteor/server/lib/media/file-upload/lib/ranges.ts
🔇 Additional comments (2)
apps/meteor/server/lib/media/file-upload/lib/ranges.ts (1)
5-10: LGTM!Also applies to: 12-39, 41-54
apps/meteor/server/lib/media/file-upload/lib/ranges.spec.ts (1)
12-49: LGTM!Also applies to: 56-59
|
@abhinavkrin hey, can you mention the root cause here? |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-8.7.0 #41588 +/- ##
=================================================
+ Coverage 68.43% 68.45% +0.01%
=================================================
Files 4142 4143 +1
Lines 158390 158442 +52
Branches 28335 28278 -57
=================================================
+ Hits 108399 108454 +55
+ Misses 44856 44854 -2
+ Partials 5135 5134 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Root Cause #41120The
|
|
what if we call it |
|
Yep, not a regression. The bug with range headers has existed for quite some time. The only problem is that before, the UI loaded the full audio in memory and that allowed seeking. I'd vouch for moving this as a fix and discuss if we should target this release version or next 👀 |
7a480da to
279dc95
Compare
|
I would say we can call this fix. And in the changeset we mention that range header fix. |
279dc95 to
107bd41
Compare
Approved by backend. Reviewer comments addressed,
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
- Remove implementation comments per repo guideline - Advertise Accept-Ranges: bytes on all upload responses, not only ranged ones - Cover inverted closed range in getFileRange tests Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
4d7df73 to
2e9baee
Compare
Proposed changes (including videos or screenshots)
Seeking an audio (or video) attachment with the progress slider snapped back to
0and would not move. The browser reported the media as non-seekable (seekable = [[0, 0]]) despite a known duration and buffered data.The root cause was server-side. Media requests are answered by
getFileRange, whose header parser only matched fully-closed ranges (bytes=a-b). Browsers request media with open-ended ranges instead:bytes=0-on load andbytes=N-on seek. These failed to parse, so the server fell through to a gzipped200response instead of a206 Partial Content, and a200/gzip response is non-seekable by definition.Changes:
bytes=N-) and suffix (bytes=-N) ranges, not just closed ones, and anchor the pattern to thebytes=unit.416).Accept-Ranges: bytesso browsers know ranged requests are supported.With a valid range parsed, the server takes the
206+ range-extract branch and bypasses gzip, restoring seekability for all audio/video served from both GridFS and FileSystem storage. Added unit tests forgetFileRangecovering open-ended, closed, suffix, clamping, and out-of-range cases.Issue(s)
CORE-2477
Steps to test or reproduce
Further comments
Server-side change — a full Meteor server restart is required to pick it up (client HMR is not enough).
CORE-2477
Summary by CodeRabbit