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

fix: nextjs ui throws exception on error ts file #208

Merged

Commits on Oct 24, 2023

  1. fix: nextjs ui throws exception on error ts file

    Occasionally (not all the time), whenever I start up the local frontend full stack Next.js webapp, and then attempt to load the frontend UI after the Next.js servers are up and ready, the browser displays an exception thrown by Next.js.
    
    The exception which is occasionally thrown, throws with the error message `Attempted to call getErrorMessage() from the server, but getErrorMessage is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a client component.`.
    
    💡 It seems that the `error.ts` file from which the `getErrorMessage()` function is defined conflicts with the reserved Next.js app router keyword for `error.tsx` components, and so Next.js (mistakenly) assumes `error.ts` is client component file, and hence why `use client` was placed at the top of the `error.ts` file in the first place to overcome the initial error. However, in hindsight this is not the correct solution as the function should be called on the server-side, and so the solution is to instead rename `error.ts` to `errors.ts`, which also makes more logical sense, and can be extended with additional error handling functions in future.
    
    This change resolves issue srbhr#207.
    Sayvai committed Oct 24, 2023
    Configuration menu
    Copy the full SHA
    b283d9c View commit details
    Browse the repository at this point in the history