Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hatem-amer opened this issue Dec 31, 2024 · 0 comments
Open

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

hatem-amer opened this issue Dec 31, 2024 · 0 comments
Labels
Priority: Normal Minor issue impacting one or more users Type: Bug Something isn't working

Comments

@hatem-amer
Copy link

hatem-amer commented Dec 31, 2024

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
@hatem-amer hatem-amer added Priority: Normal Minor issue impacting one or more users Type: Bug Something isn't working labels Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Normal Minor issue impacting one or more users Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant