Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextRenderError is not working #1011

Open
2 tasks done
breftejk opened this issue Jun 27, 2024 · 1 comment
Open
2 tasks done

nextRenderError is not working #1011

breftejk opened this issue Jun 27, 2024 · 1 comment

Comments

@breftejk
Copy link

breftejk commented Jun 27, 2024

Prerequisites

  • I have written a descriptive issue title
  • 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:

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.

@mcollina
Copy link
Member

I have a rough feeling we would need to deprecate this module. Some of the intricacies of Next.js are too hard to overcome :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants