Skip to content

feat: warn when download handler does not answer range request - #26340

Merged
Artur- merged 22 commits into
mainfrom
feat/warn-media-source-without-ranges
Oct 14, 2026
Merged

Artur- merged 22 commits into
mainfrom
feat/warn-media-source-without-ranges

Conversation

@totally-not-ai

@totally-not-ai totally-not-ai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

DX/docs · flow-server · apps that serve audio, video or large
downloads from a built-in DownloadHandler

A built-in download handler that does not answer byte range requests
serves the whole file instead, so a media player cannot seek in it,
Safari does not play it, and a download cannot resume. Ranges are off
by default for every built-in handler except forFile, and nothing
told the developer. Now a warning in development mode names the
handler and the ways to fix it.

Risks:

  • ✅ No API change, no behaviour change; in production mode nothing is
    logged, and the check is one header lookup per transfer without
    ranges

  • The built-in handlers now log a development-mode warning when they
    are about to serve the whole content for a request with a Range
    header, naming the cause and what to do about it: ranges are not
    enabled, the content length is unknown, or the response is not an
    HTTP servlet response

    • Logged before the transfer, so it appears right away and also when
      the player drops the connection
    • Not logged for a missing resource or an error response, which
      return before any transfer, nor for custom handlers, which may
      answer ranges themselves
    • Logged once per handler class, cause and application, naming the first
      file and saying that other files served the same way are affected
      too; tracked by class name in an attribute of the VaadinContext

In development mode, log a warning when a Source is given a download
handler that does not answer byte range requests, since the player
cannot seek in such a file and Safari does not play it.
@totally-not-ai

totally-not-ai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Type of change

  • Feature

How to test

  1. Run flow-tests/test-root-context in development mode and open MediaComponentsView (flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/MediaComponentsView.java)
  2. Let the audio player load its file, then look at the server log
  3. One warning says that the download handler com.vaadin.flow.server.streams.InputStreamDownloadHandler does not answer byte range requests; reloading the view does not log it again

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

 1 659 files  ±0   1 744 suites  ±0   2h 8m 16s ⏱️ +22s
12 851 tests +3  12 779 ✅ +3  72 💤 ±0  0 ❌ ±0 
13 484 runs  +3  13 412 ✅ +3  72 💤 ±0  0 ❌ ±0 

Results for commit 9531198. ± Comparison against base commit 8e3ffbf.

♻️ This comment has been updated with latest results.

@Artur-
Artur- marked this pull request as ready for review October 12, 2026 16:28

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the changes — left 1 comment.

Finding
⚠️ For a lambda download handler the warning names a synthetic class, not anything the developer can act on.

Warn from the handler that Source serves the media file through, the
first time the browser requests a byte range that the handler does not
answer. This reads isRangeRequestsEnabled() when it matters, keeps no
global state and registers no attach listener.
Move the development-mode warning from Source to the request path of
DownloadHandler, so that it covers every handler, logs once per handler
class and application, and leaves Source serving the handler through
allowDisabled() as before. The wrapper of allowDisabled() now delegates
handleRequest, so an override of it in the wrapped handler is used.
@totally-not-ai totally-not-ai Bot changed the title feat: warn when media source handler does not answer ranges feat: warn when download handler does not answer range request Oct 13, 2026
Check the response after the handler has run, so a failed request or a
handler that answers ranges itself is not warned about. Warn once per
kind of handler so that the set of warned handlers stays bounded, and
word the warning for any client that requests ranges.
Warn whenever a handler that does not answer byte ranges receives a
range request, and word the warning as the whole file being served
instead of the range.
Log the warning from the transfer of the built-in download handlers,
right before they serve the whole content for a range request. It then
appears before any byte is written, also when the client drops the
connection, and not for a missing resource, an error response or a
custom handler that answers ranges itself. Restore DownloadHandler and
allowDisabled() to their previous behaviour.
Also warn when a built-in handler with ranges enabled serves the whole
file because the content length is unknown or the response is not an
HTTP servlet response, naming the cause and what to do about it.
caalador
caalador previously approved these changes Oct 13, 2026
@Artur-
Artur- added this pull request to the merge queue Oct 14, 2026
@Artur-
Artur- removed this pull request from the merge queue due to a manual request Oct 14, 2026
Artur- and others added 2 commits October 14, 2026 10:28
Pass the handler type and served URL as logger arguments instead of
concatenating them, and explain the empty handler in the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@totally-not-ai

Copy link
Copy Markdown
Contributor Author

@sonarqubecloud Fixed all three in a new commit:

  • UnansweredRangeRequests: the handler type and the "serving ''" suffix are now logger placeholder arguments instead of one concatenated argument. The ternary that builds the suffix is computed beforehand and parenthesized. The logged message text is unchanged.
  • AbstractDownloadHandlerTest: added a comment to the empty handleDownloadRequest. It's never called; the test only needs a second handler class to check that warnings are kept per class.

Artur-
Artur- previously approved these changes Oct 14, 2026
@Artur-
Artur- enabled auto-merge October 14, 2026 07:56
@Artur-
Artur- added this pull request to the merge queue Oct 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 14, 2026
@Artur-

Artur- commented Oct 14, 2026

Copy link
Copy Markdown
Member

merge main

…e-without-ranges

# Conflicts:
#	flow-server/src/test/java/com/vaadin/flow/server/streams/AbstractDownloadHandlerTest.java
@totally-not-ai

Copy link
Copy Markdown
Contributor Author

@Artur- Merged main into the branch. The only conflict was in AbstractDownloadHandlerTest, where both sides appended tests at the end of the class; kept both. The download handler tests in flow-server pass.

@Artur-
Artur- enabled auto-merge October 14, 2026 08:46
@sonarqubecloud

Copy link
Copy Markdown

@Artur-
Artur- added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit 54b28ba Oct 14, 2026
@Artur-
Artur- deleted the feat/warn-media-source-without-ranges branch October 14, 2026 10:25
@github-actions

Copy link
Copy Markdown
Contributor

Documentation Bot: No documentation needed for this change.

This is a BEHAVIOR_CHANGE-shaped addition that is purely diagnostic: built-in download handlers now log a development-mode warning when they cannot answer a byte range request, explaining the cause. There is no API change, no production-mode behavior change, and no new configuration surface for a reader to act on—a developer learns about this directly from the server log at the moment it applies to them.

Nothing was opened in vaadin/docs. If you disagree, the change has to be documented by hand there.

Generated by Documentation Bot for #26340 · agent · 28 AIC · ⊞ 11.7K · ◷

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.4.0-alpha4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants