Return ReadableStream from form action
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
We can return a ReadableStream from an endpoint in +server.ts, but trying to do the same from a form action in +page.server.ts makes Sveltekit complain that the data returned is not serializable.
I might be missing a reason why this isn't a good idea, but it would be convenient for me. In my case I allow the user to upload many files, some of which might be quite large. I would like to push status messages back to the user as the files are written on the server.
Describe the proposed solution
Allow returning ReadableStream from form actions.
Alternatives considered
I could just use an API route, but then to handle the streamed response I need to use browser-side fetch to submit, which means users without JS can't upload files (I think?).
In an ideal world, users without JS can still upload files, they just can't see any progress updates.
Importance
nice to have
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing how a ReadableStream is returned from an endpoint in +server.ts with the serialization behavior of form actions in +page.server.ts. Determine the constraints around streamed form-action responses, including non-JavaScript uploads, and confirm that a supported design allows progress messages without breaking regular form submission.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100