Skip to content

Feature request: inject streams into streams #12

@vstefanovic97

Description

@vstefanovic97

Right now it seems like if we want to inject some content from a sub request we would use an async handler like so:

async element(e) {
  const response = await fetch(url); // make sub request
  const text = await response.text(); // whole text buffered in memor, this blocks from sending more data until we get full response
  e.append(text); // insert text into main content
}

But isn't this sort of wasteful a bit, I mean we are needing to buffer the whole subrequest in memory and need to wait for the whole response to finish.
Wouldn't it be better if the rewritter would support something like this:

async element(e) {
  const response = await fetch(url); // make sub request
  e.append(response.body); // if stream provided it is correctly injected and streamed
}

In this case we will be returning the sub requests chunks as soon as they come and won't buffer them fully in memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions