blitz-js / legacy-framework

MIT License
2 stars 2 forks source link

Send Query or Mutaion API error logs to monitoring tool #155

Closed chimame closed 2 years ago

chimame commented 2 years ago

What do you want and why?

Following the RPC specification, a Query or Mutation is returned with an http status of 200. Therefore, at this time, errors such as Query must be handled on the client side.

We would like to be able to detect errors that occur on the server side. This is because we need to send the error content from the client in order to send it to monitoring tools such as Sentry or Google Cloud Error Report, for example.

Possible implementation(s)

I am implementing error handling with rpc middleware, but I cannot retrieve the error object. So it is difficult to send it to monitoring tools, etc. I can come up with the following idea.

  1. make it possible to retrieve the Error object after next() is executed
  2. pass the process in case of an error in the configuration and pass the error object in case of an error.

https://github.com/blitz-js/blitz/blob/d41385b5928503b58b13bdc2d3a9985278b93d99/nextjs/packages/next/server/api-utils.ts#L252-L273

Additional context

I would like to develop Blitz if we can discuss the proposed implementation and decide on a direction.

beerose commented 2 years ago

This is something we talked about regarding Blitz Toolkit. We were thinking about having an error middleware that would cover the use cases as sending info to monitoring tools.

chimame commented 2 years ago

@beerose Thanks for the response!

So you are saying that this issue will not be tackled in the current Blitz, but will be tackled in the Blitz Toolkit? If there is anything I can help you with in the Blitz Toolkit, please let me know.

beerose commented 2 years ago

@chimame Yes, it will be tackled in the toolkit! Here's the related issue: https://github.com/blitz-js/blitz/issues/3200. It's currently blocked on the initial RPC setup: https://github.com/blitz-js/blitz/issues/3196. So once blitz-js/blitz#3196 is done, we can start discussing possible implementations of the error middleware.

beerose commented 2 years ago

This was covered by https://github.com/blitz-js/blitz/pull/3460