nextjs API routes become unresponsive in dev mode

I am encountering a problem where the API routes become completely unresponsive in dev mode. To demonstrate this, I have created this minimal example. https://github.com/amit13k/create-t3-app-example2 The changes that were made to the generated t3 app are as follows, 1. top level await was enabled
webpack: (config, options) => {
config.experiments = {
"topLevelAwait": true,
"layers": true
};
return config;
},
webpack: (config, options) => {
config.experiments = {
"topLevelAwait": true,
"layers": true
};
return config;
},
2. There is an api route called example which uses an export named "someValue" from "src/lib/someModule". 3. In the file "someModule", "someValue" is exported similarly to how prisma get's exported to prevent problems related to multiple instances during npm run dev. "/api/example" works fine the first time. But if we make some changes to src/pages/index.tsx which leads to fast refresh, /api/example becomes unresponsive. I am not entirely sure why this happens, but it definitely seems related to node global and the top level await being used. If I don't use an async function with top-level await (rest everything being the same), this problem doesn't happen. Trying to understand why this happens and looking for suggestions on how to make this work with async functions.
GitHub
GitHub - amit13k/create-t3-app-example2
Contribute to amit13k/create-t3-app-example2 development by creating an account on GitHub.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server