Skip to content

Server render() result shape is impractical to work with #16934

@florian-lefebvre

Description

@florian-lefebvre

Describe the bug

When awaiting render() when compilerOptions.experimental.async isn't enabled, the experimental_async_ssr warning is shown. Problem is, there's no way to know if the result is awaitable from its shape because then is always present: https://github.com/sveltejs/svelte/blob/main/packages/svelte/src/internal/server/renderer.js#L352-L384. That's an issue for us in Astro.

My recommendation would be to only set the then property if async_mode_flag is true so we can do checks like 'then' in result:

let result = render(...)
if (isPromise(result)) {
  result = await result
}

That currently forces us to make a pretty big workaround, see withastro/astro#14526.

I'd be happy to open a PR

Reproduction

See withastro/astro#14508 and https://stackblitz.com/edit/github-tpnsqnas?file=src%2Fpages%2Findex.astro

Logs

System Info

N/A

Severity

annoyance

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