Nitro Engine does not support Async Higher Order Functions
See original GitHub issueEnvironment
- Operating System:
Darwin
- Node Version:
v16.12.0
- Nuxt Version:
3.0.0-27252861.4f9c87b
- Package Manager:
npm
- Bundler:
Webpack
- User Config:
vite
- Runtime Modules:
-
- Build Modules:
-
Describe the bug
Async Higher-Order Functions on API Routes are not supported always return a handle is not a function.
Reproduction
// api/graphql.ts
async function main() { return function () { return { hello: “World” }; }; }
export default main();
Additional context
No response
Logs
status code: 500
handle is not a function
at file://./node_modules/h3/dist/index.mjs:111:24
at new Promise (<anonymous>)
at callHandle (file://./node_modules/h3/dist/index.mjs:108:10)
at file://./node_modules/h3/dist/index.mjs:104:12
at file://./node_modules/h3/dist/index.mjs:132:34
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async handle (file://./node_modules/h3/dist/index.mjs:572:19)
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
async/await not working with with higher order functions #123
I have a function I need to pass arguments to, so I decided to use a higher order function like this const signupController...
Read more >What happened to async compute? : r/Amd - Reddit
Most games run pretty much the same on GTX 1060 and RX 480/580. Has async compute just not been adopted? This thread is...
Read more >Async agnostic higher order functions - Stack Overflow
Suppose we have a library that provides a higher order function applyTest . Can this be used with an asynchronous function asyncFunction ......
Read more >Discussion on Async Compute from AMD Prospective
I want to know more about how AMD uses Async Compute vs how Nvidia does it. With Turing cards released yesterday it's very...
Read more >AMD Dives Deep On Asynchronous Shading - AnandTech
Key among the latter features set is support for asynchronous shaders ... AMD has offered multiple Asynchronous Compute Engines (ACEs) since ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you want to avoid top level await as mentioned in earlier example, try this:
This is nice with
apollo-server-h3
💚Nitro itself lazy loads API routes on the first call but we can do something like this:
Please don’t hesitate to DM me or open a discussion to continue this 😃