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

External API response is cut off when proxying with rewrites #53737

Closed
1 task done
yamashhh opened this issue Aug 8, 2023 · 10 comments
Closed
1 task done

External API response is cut off when proxying with rewrites #53737

yamashhh opened this issue Aug 8, 2023 · 10 comments
Labels
bug Issue was opened via the bug report template. locked

Comments

@yamashhh
Copy link

yamashhh commented Aug 8, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
    Binaries:
      Node: 16.17.0
      npm: 8.15.0
      Yarn: 1.22.19
      pnpm: 7.1.0
    Relevant Packages:
      next: 13.4.13-canary.13
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.3
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

https://codesandbox.io/p/sandbox/competent-tess-gdqf3w

To Reproduce

  1. Create a proxy for an external API endpoint by setting rewrites in next.config.js
  2. Consume the API in an arbitrary component
  3. Check the response from the API

Describe the Bug

The response JSON is cut off.

Screenshot 2023-08-09 at 0 33 32

Expected Behavior

The entire API response is available.

Confirmed working when downgraded to v13.2.4.
repro: https://codesandbox.io/p/sandbox/vibrant-http-j6wnzr

    Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
    Binaries:
      Node: 16.17.0
      npm: 8.15.0
      Yarn: 1.22.19
      pnpm: 7.1.0
    Relevant packages:
      next: 13.2.4
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

These issues/discussions might be related:

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@yamashhh yamashhh added the bug Issue was opened via the bug report template. label Aug 8, 2023
@icyJoseph
Copy link
Contributor

Do you have to downgrade all the way to 13.2.4 for it to break? I can try to do a bit of searching on which commit broke it, but I'd just like some confirmation that 13.2.5 for example is already broken.

@yamashhh
Copy link
Author

yamashhh commented Aug 9, 2023

@icyJoseph

Hi, I've found out that this specific problem might be fixed in the latest canary version,
here is the breakdown:

Next.js version Reproduces
v13.4.12 NO
v13.4.13 YES
v13.4.14-canary.1 NO

Confirmed on local machine:

    Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64
    Binaries:
      Node: 18.16.1
      npm: 9.5.1
      Yarn: 1.22.19
      ppm: 8.6.9
    Relevant Packages:
      next: 13.4.14-canary.1
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.3
    Next.js Config:
      output: N/A

This is the code I used, sorry I had to move from Codesandbox because it was laggy.

@icyJoseph
Copy link
Contributor

icyJoseph commented Aug 9, 2023

Awesome, no worries. You can also use Stackblitz from GitHub, like this:

https://stackblitz.com/github/yamashhh/nextjs-issues-53737

Though there seems to be an issue with Next.js there.

Anyway, so if its fixed in canary, then I guess we could close the issue?

@yamashhh
Copy link
Author

yamashhh commented Aug 9, 2023

You can also use Stackblitz from GitHub

This is nice to know!

Thanks for checking in, I'll close this issue and see if it'll be fixed in the next stable release.

@ian-hutchinson
Copy link

@yamashhh Did you ever verify this in a stable release?

I'm seeing very similar issues in dev when proxying requests on version 13.4.19.

It feels like something has fundamentally changed with the chunking. I do not see the issue in 13.4.12.

@yamashhh
Copy link
Author

@ian-hutchinson

Sorry, I haven't updated this thread.
It seems the problem doesn't reproduce on v13.4.19 for my specific use case.

example on stackblitz

@tkmcmaster
Copy link

tkmcmaster commented Aug 22, 2023

My use case seems intermittent. I thought it was fixed by the canary release (and it worked locally) but is truncated still when deployed in AWS with any of the released versions 13.4.4 - 13.4.19. So I'm still rolled back to 13.3.4

@ra-lfaro
Copy link

@yamashhh Did you ever verify this in a stable release?

I'm seeing very similar issues in dev when proxying requests on version 13.4.19.

It feels like something has fundamentally changed with the chunking. I do not see the issue in 13.4.12.

exact same here

@ra-lfaro
Copy link

after lots of digging i was able to resolve my issue by removing the content-length on the proxy response. This wasnt an issue until upgrading from 13.4.12 to 13.4.19

@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2023

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot added the locked label Sep 6, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked
Projects
None yet
Development

No branches or pull requests

5 participants