Skip to content

Provide diagnostics when HTTP response bodies approach maxResponseBodySize #69388

@m-aciek

Description

@m-aciek

Which @angular/* package(s) are relevant/related to the feature request?

platform-server

Description

Angular SSR currently enforces maxResponseBodySize (default: 1 MB) for HTTP responses fetched during server-side rendering.

When the limit is exceeded, rendering fails with an error. However, there is currently no built-in mechanism to detect that an application is gradually approaching the limit.

As a result, developers often discover the issue only after a deployment, when an API response grows enough to trigger failures in production (sample).

The current behaviour is effectively a hard failure at 100% utilization with no early feedback. Providing warnings at configurable thresholds would turn an abrupt runtime error into an actionable signal during development and testing.

Proposed solution

Expose diagnostics when the accumulated response size approaches the configured limit.

Possible API:

provideServerRendering(
  withHttpTransferCache({
    maxResponseBodySize: 1_000_000,
    warningThreshold: 0.8,
    onResponseBodySizeWarning: (event) => {
      console.warn(event);
    },
  }),
);

where:

interface ResponseBodySizeWarning {
  url: string;
  receivedBytes: number;
  maxResponseBodySize: number;
  percentage: number;
}

Alternatives considered

If a public API is considered too large, Angular could emit development-mode warnings by default, for example once the response size exceeds 80% of the configured limit:

SSR HTTP response body size approaching configured limit:
  URL: /api/products
  Size: 842 kB / 1000 kB (84%)

Production builds could remain silent unless explicitly configured.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: common/httpIssues related to HTTP and HTTP Clientarea: serverIssues related to server-side rendering

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions