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

Fix unhandled rejection in proxy-request #72530

Merged
merged 2 commits into from
Nov 18, 2024
Merged

Conversation

JeremieDoctrine
Copy link
Contributor

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 instances schedules a function to be called when the promise is settled (either fulfilled or rejected). It immediately returns another Promise object, allowing you to chain calls to other promise methods.

Why?

see : #72522

How?

Fixes : #72522

@ijjk ijjk added the type: next label Nov 9, 2024
@JeremieDoctrine JeremieDoctrine changed the title Update proxy-request.ts Fix unhandled rejection in proxy-request Nov 9, 2024
@JeremieDoctrine
Copy link
Contributor Author

@wyattjoh (sorry for the random ping but you were the last one committing on this file) Is there any chance you can help me in getting this merged 🙇

I'm quite confident this is a real issue and I'm sure people will encounter it when upgrading to Next.js 15 as we did 😬

@wyattjoh wyattjoh merged commit fc3c96d into vercel:canary Nov 18, 2024
86 checks passed
@JeremieDoctrine
Copy link
Contributor Author

Thanks a lot !

wyattjoh added a commit that referenced this pull request 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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unhandled rejection when using rewrite proxy
3 participants