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

[BUG] Streaming does not work for API routes #152

Open
vicb opened this issue Dec 6, 2024 · 2 comments
Open

[BUG] Streaming does not work for API routes #152

vicb opened this issue Dec 6, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@vicb
Copy link
Contributor

vicb commented Dec 6, 2024

Describe the bug

See #102 (comment) (reported by @dandoen)

Streaming does not work for API routes (The whole response is sent at once)

Steps to reproduce

Use the code in the linked comment

Expected behavior

Streaming works

@opennextjs/cloudflare version

experimental branch as of Dec 6

Node.js version

22

Wrangler version

Custom - > 3.92

next info output

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:00:32 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: N/A
  pnpm: 9.14.4
Relevant Packages:
  next: 14.2.11 // An outdated version detected (latest is 15.0.4), upgrade is highly recommended!
  eslint-config-next: 14.2.14
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.4

Additional context

No response

@vicb vicb added bug Something isn't working triage and removed triage labels Dec 6, 2024
@vicb
Copy link
Contributor Author

vicb commented Dec 6, 2024

@dandoen I was playing with your example this morning and noted something:

The stream route is statically rendered

image

If you force the route to be dynamic:

export async function GET(request: NextRequest) {
  headers().has("whatever");
  // ...
});

Then the route is dynamic:

image

And streaming works as expected.

Still next dev streams without having to force the route to be dynamic.

@dandoen
Copy link

dandoen commented Dec 6, 2024

Oh wow, good spot. Confirmed. Thx @vicb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants