nodejs api is not working with next.js backend api
I tried to run genaiscript in next.js endpoint but for some reason the endpoint was hanging for every when I try to run same script using just nodejs everything works as expected
-
Describe the problem: The user is experiencing an issue where running a GenAISCript in a Next.js backend API endpoint causes the endpoint to hang, whereas running the same script using just Node.js works as expected.
-
Steps to reproduce:
- Run the GenAISCript in a Next.js endpoint.
- Observe that the endpoint hangs.
-
Environment:
- Node.js
- Next.js
-
Additional information:
- The script runs correctly when executed using just Node.js.
- No error messages are provided by the API endpoint.
Further details needed:
- Which version of GenAISCript is being used?
- Is there a specific library or dependency that needs to be imported in the Next.js environment?
- Are there any environment variables or configuration files required for GenAISCript to run in the Next.js environment?
- What additional logging or debugging information can be provided to help identify the issue?
AI-generated content by issue-reviewer may be incorrect
Do you have access to any logs?
Do you have access to any logs?
I don't see any logs when, is there is any flags I can use? I can see logs when I run from node script.js but not with next.js api endpoint as well
something come to my mind maybe next.js not support nodejs api I remember reading something related before
Do you have documentation about next.js hosting? It's most likely a sandboxed JS runtime with limitation on file system io.
Do you have documentation about next.js hosting? It's most likely a sandboxed JS runtime with limitation on file system io.
it was just new next.js project running local with turbo, for now I just used express.js server in the script file it self and used it from there as api
async function startServer() {
const expressApp = express();
const port = 3000;
expressApp.get("/", async (req, res) => {
const query = req.query.q as string;
try {
checkpointer.storage = {};
checkpointer.writes = {};
const result = await app.invoke(
{
messages: [
{
content: query,
role: "user",
},
],
},
{}
);
res.json(result.messages.at(-1).content);
} catch (error) {
res.status(500).json({ error: "Failed" });
}
});
// Handle cleanup when the server is shutting down
process.on("SIGINT", async () => {
console.log("Shutting down server...");
process.exit(0);
});
// Return a Promise that keeps the process alive
return new Promise((resolve, reject) => {
const server = expressApp.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
server.on("error", (error) => {
reject(error);
});
});
}
The user is experiencing issues running a GenAISCript in a Next.js backend API endpoint, causing the endpoint to hang. Running the same script using just Node.js works as expected. No error messages are provided by the API endpoint, and there are no logs available when running from the Next.js API endpoint.
It's suggested that this could be due to limitations imposed by Next.js on file system I/O, which could affect the script. The user has tried using Express.js within their Next.js project as an API server but still encountered the hanging issue.
AI-generated content by issue-bot may be incorrect