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

Unhandled rejection when using rewrite proxy #72522

Closed
JeremieDoctrine opened this issue Nov 8, 2024 · 2 comments · Fixed by #72530
Closed

Unhandled rejection when using rewrite proxy #72522

JeremieDoctrine opened this issue Nov 8, 2024 · 2 comments · Fixed by #72530
Labels
bug Issue was opened via the bug report template. locked

Comments

@JeremieDoctrine
Copy link
Contributor

JeremieDoctrine commented Nov 8, 2024

Link to the code that reproduces this issue

https://github.com/JeremieDoctrine/next-proxy-issue

To Reproduce

pnpm install
pnpm run dev
curl http://localhost:3000/proxy-path

You can see in the logs

⨯ unhandledRejection: [Error: getaddrinfo ENOTFOUND not-existing-host] {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'not-existing-host'
}

Current vs. Expected behavior

Currently the proxy is throwing an unhandledRejection.

The expected behavior is not to throw an unhandledRejection.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:38:45 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8122
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 21.7.3
  npm: 10.5.0
  Yarn: 1.22.22
  pnpm: 9.12.3
Relevant Packages:
  next: 15.0.4-canary.2 // Latest available version is detected (15.0.4-canary.2).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local), Other (Deployed)

Additional context

The issue was introduced in this PR : #65759 from @wyattjoh

Commenting this line :

fixes the issue but i'm not sure what is the expected behavior.

@JeremieDoctrine JeremieDoctrine added the bug Issue was opened via the bug report template. label Nov 8, 2024
@JeremieDoctrine
Copy link
Contributor Author

I tried a fix here : #72530

wyattjoh added a commit that referenced this issue Nov 28, 2024
Trying to fix : #72522

### What?
The finally method actually creates a new promise. You have to listen to
this new promise instead of the original one or you might end up with
unhandled rejection.

Taken from the documentation : 
> The finally() method of
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
instances schedules a function to be called when the promise is settled
(either fulfilled or rejected). It immediately returns another
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
object, allowing you to
[chain](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#chaining)
calls to other promise methods.

### Why?
see : #72522

### How?

Fixes : #72522

Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
Copy link
Contributor

github-actions bot commented Dec 3, 2024

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 Dec 3, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2024
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

Successfully merging a pull request may close this issue.

1 participant