Skip to content

Support Server-Sent Events (SSE) with adapter-node #887

Description

@babeard

Describe the bug
While migrating a sapper app to svelte-kit / adapter-node, I came across a feature that seems to be missing. Namely, the ability to create custom middleware that can handle Server-Sent Events or other long-lived connections that send data to the response stream without closing the connection. Since the handle hook requires returning Response | Promise<Response>, thus closing the connection, it does not support this. Nor have I found any other way to res.write(); using endpoints.

Information about your SvelteKit Installation:

Diagnostics
System:
    OS: Linux 4.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
    Memory: 7.97 GB / 15.94 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
Binaries:
    Node: 14.5.0 - ~/.nvm/versions/node/v14.5.0/bin/node
    npm: 6.14.5 - ~/.nvm/versions/node/v14.5.0/bin/npm
npmPackages:
    @sveltejs/kit: ^1.0.0-next.68 => 1.0.0-next.68
    svelte: ^3.37.0 => 3.37.0
    vite: ^2.1.5 => 2.1.5
  • Using node-adapter

Severity
Adds a bit of friction for migrating from Sapper, reduces feature parity, and will require me to either
a) regress to polling the server from the client, or
b) write a custom adapter for every project that needs SSEs. (which I'm not sure that this even helps for the development environment anyways)

Additional context
Issue #334 seems relevant.

Also originally asked within discord chat but no one seems to know the answer, which is why I am submitting this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions