fastify / fastify/fastify-nextjs
nextRenderError is not working
- Dominant language
- JavaScript
- Stars
- 558
- Forks
- 62
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 6
Description
### Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the bug has not already been reported
### Fastify version
4.28.0
### Plugin version
10.0.1
### Node.js version
22.2.0
### Operating system
macOS
### Operating system version (i.e. 20.04, 11.3, 10)
15.0
### Description
I am unable to get @fastify/nextjs to render an error page.
Everything else works perfectly, except for the error page rendering.
The error handler is being called, and it logs “error handler called”. However, the request keeps loading indefinitely until it eventually times out.
I have tried various approaches, such as returning the error, making the error a string, returning JSON, and more. Despite these efforts, the request just hangs without any further errors.
Here is my code:
```ts
import type { Theme } from "@discord-dashboard/typings";
import type { Dashboard } from "@discord-dashboard/core";
import FastifyNextJS from "@fastify/nextjs";
import * as path from "node:path";
export default class BaseTheme extends Theme {
name = "Base";
async Initialize(dashboard: Dashboard) {
await dashboard.fastify.register(FastifyNextJS, {
logLevel: dashboard.Environment.log_level,
dir: path.join(__dirname, "../")
});
dashboard.fastify.next('/fugg', async (app, request, reply) => {
throw new Error("me");
});
dashboard.fastify.setErrorHandler(async (error, request, reply) => {
console.log("error handler called");
await reply.nextRenderError(error);
});
}
}
```
### Link to code that reproduces the bug
_No response_
### Expected Behavior
It is expected to render an error page.
Contributor guide
Assessment
This issue has not been assessed yet.