Skip to content

[labs/ssr] Truncated response #4187

@robak86

Description

@robak86

Which package(s) are affected?

SSR (@lit-labs/ssr)

Description

During the rendering of a component having a list with 1000 elements, the SSR response is truncated - only some part of the items is rendered.

Reproduction

https://stackblitz.com/edit/lit-ssr-global-wydn3p?file=src%2Fcomponents%2Fsimple-greeter.js

Workaround

The error happens in RenderResultReadable, in a code branch, which is executed when the consumer cannot accept more data (https://github.com/lit/lit/blob/bb4d10704e82cd4ebfea6dede662e6233bb4c086/packages/labs/ssr/src/lib/render-result-readable.ts#L76C11-L76C18). We return from the _read, but the iterator may still have next values. On the subsequent _read call, we pop the next iterator (https://github.com/lit/lit/blob/bb4d10704e82cd4ebfea6dede662e6233bb4c086/packages/labs/ssr/src/lib/render-result-readable.ts#L60C38-L60C38), ignoring the values from the previous iterator that were not sent because of back pressure.

Probably the correct approach would be to keep the current iterator as an instance variable so that when the subsequent _read is called, we can send the rest of the values from the previous call.

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

3.1.2

Browser/OS/Node environment

Browser: 116.0.5845.179
OS: 13.5.1
Node: v18.17.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions