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

Reply.from inside async handler cause Promise may not be fulfilled with 'undefined' when statusCode is not 204 #105

Closed
ngkhnam opened this issue Oct 13, 2020 · 4 comments

Comments

@ngkhnam
Copy link

ngkhnam commented Oct 13, 2020

🐛 Bug Report

when using reply.from inside async request handler will cause error "Promise may not be fulfilled with 'undefined' when statusCode is not 204"

To Reproduce

Steps to reproduce the behavior:
the handle code:
/node_modules/fastify/lib/wrapThenable.js:30:30

 `server.get('/', async (req, reply) => {
            //...some code here
            reply.from('<other url>');
});`

Expected behavior

no error message

Your Environment

  • node version: 10
  • fastify version: 3.6.0
  • os: Mac
  • any other relevant information
@mcollina
Copy link
Member

you should do return reply at the end.

@ngkhnam ngkhnam closed this as completed Oct 27, 2020
@ngkhnam
Copy link
Author

ngkhnam commented Oct 27, 2020

thank @mcollina

@SimenB
Copy link
Member

SimenB commented Feb 24, 2021

Can that be added to the error message somehow?

Is the general rule that if you do reply.* that handles the request (like reply.redirect or reply.from) in an async handler that you should always return it?

@mcollina
Copy link
Member

Can that be added to the error message somehow?

Yes, definitely. On this topic there is fastify/fastify#2860 if you want to refactor that area of Fastify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants