Closed yaneony closed 2 years ago
Is that expected behavior?
I don't think so
Would you like to send a Pull Request to address this issue? Remember to add unit tests.
I'm not sure what and where the problem is.
Is returning actually correct? reply.view is a promise. So returning reply.view in the async await is an unresolved Promise, and as such "undefined".
So I think, you should remove the returns. It is also clarified in the docs. https://www.fastify.io/docs/latest/Routes/#promise-resolution
I think the view
method should return the res
object
this will both code usages work
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Prerequisites
Fastify version
latest
Plugin version
latest
Node.js version
latest
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
Windows 10-11 / Debian 10-11
Description
Following code was used (see below)
Open /1 in your browser and just hold on F5.. you will get a lot of errors in your console with following message:
[1636309790914] ERROR (18208 on DESKTOP): Promise may not be fulfilled with 'undefined' when statusCode is not 204
While, doing same on /2 is working fine.
As per documentation, and also example from here https://github.com/fastify/point-of-view/blob/master/example-async.js#L25 it should be fine to reply.view without await, but it looks like you'll have to use await as well.
Is that expected behavior?
Steps to Reproduce
Expected Behavior
No response