Skip to content

Conversation

@marshallswain
Copy link
Member

This PR adds the ability to stream data into Feathers services using ReadableStream.

Changes

Client (packages/feathers/src/client/fetch.ts)

  • Auto-detects ReadableStream and passes it directly to fetch
  • Sets duplex: 'half' for streaming bodies
  • Defaults to application/octet-stream if no Content-Type specified

Server (packages/feathers/src/http/middleware.ts)

  • Streams unknown content types directly to services instead of throwing an error
  • JSON and form-urlencoded are parsed as before
  • Everything else passes through as a ReadableStream

Test Fixture (packages/feathers/fixtures/index.ts)

  • Replaced @whatwg-node/server with native Node.js adapter
  • Added StreamingService for testing

Usage

// Client - stream a file
const stream = file.stream()
await app.service('uploads').create(stream, {
  headers: {
    'Content-Type': file.type,
    'X-Filename': file.name
  }
})

// Server - pipe directly to storage
async create(stream: ReadableStream, params: Params) {
  await env.MY_BUCKET.put(params.headers['x-filename'], stream)
  return { success: true }
}

Use Cases

  • Large file uploads without buffering
  • Streaming data directly to S3/R2
  • Real-time data ingestion (IoT, logs)
  • CSV/JSON import processing row by row
  • Piping uploads through a Cloudflare Worker with minimal memory usage

Compatibility

This PR is compatible with v6-form-data. When both merge, the bodyParser will handle:

  1. application/json → parsed
  2. application/x-www-form-urlencoded → parsed
  3. multipart/form-data → parsed (from form-data PR)
  4. Everything else → streamed

Breaking Changes

None. Previously unknown content types threw an error; now they stream through.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 19, 2025

Deploying feathers-eagle with  Cloudflare Pages  Cloudflare Pages

Latest commit: 35b09d3
Status: ✅  Deploy successful!
Preview URL: https://31fcff55.feathers-a8l.pages.dev
Branch Preview URL: https://v6-streaming.feathers-a8l.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 19, 2025

Deploying feathers-dove with  Cloudflare Pages  Cloudflare Pages

Latest commit: 35b09d3
Status: ✅  Deploy successful!
Preview URL: https://0ec7482f.feathers.pages.dev
Branch Preview URL: https://v6-streaming.feathers.pages.dev

View logs

- Auto-detect ReadableStream in fetch client and pass through directly
- Stream unknown content types to services instead of throwing error
- Replace @whatwg-node/server with native Node.js adapter
- Add tests for streaming text, binary, and chunked data
- Update REST client docs with streaming upload examples
- Add createHandler for Web Standard (Request) => Response pattern
- Add toNodeHandler adapter for Node.js http.createServer
- Works natively in Deno, Bun, and Cloudflare Workers
- Node.js requires the adapter due to lack of native Web Standard server
- Add feathers/http/node export for Node.js adapter
- Add documentation for all runtimes
@daffl daffl merged commit 4c2aa85 into v6 Dec 20, 2025
6 checks passed
@daffl daffl deleted the v6-streaming branch December 20, 2025 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants