sst / sst

Build full-stack apps on your own infrastructure.
https://sst.dev
MIT License
22.02k stars 1.67k forks source link

SvelteKit: Streaming support #4622

Open martinhjartmyr opened 6 months ago

martinhjartmyr commented 6 months ago

I'm trying to enable streaming support for SvelteKit.

 const app = new sst.aws.SvelteKit('App', {
      transform: {
        server: {
          streaming: true,
          timeout: '60 seconds',
        },
      }
    })

Streaming works out of the box when running sst dev vite dev.

However, when deployed to AWS, the lambda returns JSON instead of the rendered HTML (content-type: text/html):

{"statusCode":200,"headers":{"content-type":"text/html"},"body":"<!doctype html>\n<html lang=\"en\">\n\t<head>...

Example

+page.server.ts

export const load: PageServerLoad = async () => {
  return {
    _test: new Promise((resolve) => {
      setTimeout(() => {
        resolve('Hello from the server!')
      }, 3000)
    }),
  }
}

+page.svelte

<script lang="ts">
  import type { PageData } from './$types'
  export let data: PageData
</script>

{#await data._test}
  Loading ...
{:then test}
  {test}
{/await}

Am I missing something, or is this not yet implemented?

thdxr commented 6 months ago

it's not yet implemented - i'll look into this

leon commented 2 months ago

Would it be possible to have a look at this soon? 😊

noxan commented 1 month ago

@thdxr any updates on streaming support for sveltekit? also happy to help out :)

wideving commented 1 month ago

It would be great if this feature was implemented sooner rather then later. Its kind of a blocker for us at work :) I really like sst overall, but having this feature would greatly enhance the experience.

thdxr commented 1 month ago

i will take a look at what this needs next week

wideving commented 1 month ago

Greatly appreciated, thanks.

leon commented 1 week ago

Any news on this?