Skip to content

🐛Streaming requests with the fetch API doesn't work. #1385

@hatem-amer

Description

@hatem-amer

Describe the bug
Streaming requests with the fetch API doesn't work when using Cloudflare Tunnel.

To Reproduce
Steps to reproduce the behavior:

  1. Run ./cloudflared tunnel --hello-world --protocol=http2
  2. Open the quick Tunnel URL https://xxx.trycloudflare.com in Google Chrome
  3. Run this code in the Console
function wait(milliseconds) {
  return new Promise(resolve => setTimeout(resolve, milliseconds));
}

const stream = new ReadableStream({
  async start(controller) {
    await wait(1000);
    controller.enqueue('This ');
    await wait(1000);
    controller.enqueue('is ');
    await wait(1000);
    controller.enqueue('a ');
    await wait(1000);
    controller.enqueue('slow ');
    await wait(1000);
    controller.enqueue('request.');
    controller.close();
  },
}).pipeThrough(new TextEncoderStream());

fetch("/", {
  method: 'POST',
  headers: {'Content-Type': 'text/plain'},
  body: stream,
  duplex: 'half',
});
  1. Using Wireshark we can see the cloudflared received the whole request in one DATA frame.
HyperText Transfer Protocol 2
    Stream: DATA, Stream ID: 63, Length 23
        Length: 23
        Type: DATA (0)
        Flags: 0x01, End Stream
        0... .... .... .... .... .... .... .... = Reserved: 0x0
        .000 0000 0000 0000 0000 0000 0011 1111 = Stream Identifier: 63
        [Pad Length: 0]
        Data: 54686973206973206120736c6f7720726571756573742e
    Line-based text data: text/plain (1 lines)
        This is a slow request.

Expected behavior
cloudflared should receive 5 DATA frames.

Environment and versions

  • OS: Linux debian
  • Architecture: amd64
  • Version: 2024.12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: NormalMinor issue impacting one or more usersType: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions