Log internal server errors during development by default
See original GitHub issueCurrently, I’m using the following code snippet for Next.js at the api/trpc/[trpc]
route:
import * as trpcNext from "@trpc/server/adapters/next";
const __DEV__ = process.env.NODE_ENV !== "production";
export default trpcNext.createNextApiHandler({
router: appRouter,
createContext,
onError: __DEV__
? ({ error, type, path, input }) => {
if (error.code === "INTERNAL_SERVER_ERROR") {
// eslint-disable-next-line no-console
console.error("Error:", {
type,
path,
input,
cause: error.originalError,
});
}
}
: undefined,
});
I think it would be useful to always log unhandled errors (where error.code === "INTERNAL_SERVER_ERROR"
) to the server’s console like this during development, even when no onError
is specified.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Debugging an IIS 500 – Internal server error - 4sysops
This error indicates that the number of incoming concurrent requests exceeded the number that your IIS application can process. This could be ...
Read more >How to Fix a 500 Internal Server Error on Your WordPress Site
The 500 Internal Server Error status code occurs when the server encounters an error that prevents it from fulfilling the request.
Read more >HTTP 500 Internal Server Error: What It Means & How to Fix It
An HTTP 500 internal server error is a general error message. It covers unexpected issues that don't fit into existing error codes. HTTP...
Read more >500 Internal Server Error - What is it and how to resolve it?
500 Internal Server Error is a web based error. Learn how to troubleshoot an http 500 internal server error on an IIS server...
Read more >Catching a 500 server error in Flask - python - Stack Overflow
Default exception handling that kicks in when an exception occurs that is not caught. In debug mode the exception will be re-raised immediately,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I love that you have so many ideas for improvements, if you need any guidance on how to contribute, let me know!
The reason why I wouldn’t emit messages to the console is that HTTP responses will already have an error code of 500, which Vercel and other logging services keep track of. The message about the error returned in production already contains enough information to investigate on.
I’ll try creating some PRs soon – work makes me pretty busy nowadays, sorry about that.