-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Better error reporting of cloud code bugs #6205
Comments
My team are currently tackling this issue, though we do capture information before it bubbles to Parse. For us, the issue is that we lose some information when it's dispatched back to the requesting client. I wasnt aware of the |
It appears that parse server is poised to only dispatching The As an example, if our cloud function throws an error of the instance A similar pattern occurs for errors thrown in I imagine there are other scenarios where requests created by the user, which result in exceptions thrown by our code, are intercepted and re-thrown by parse server. We would need to identify these scenarios as they will form scope of any resultant fix. Errors thrown within parse server, for example, if a request to a non-existent cloud function is received, would not have to change as part of this fix, as these are predetermined scenarios which developers should handle within their middleware. Use case:
Solution 1 (non breaking): Possible problems:
Solution 2 (breaking for applications with Possible problems:
Solution 3 (in next comment) -- In either case - we'll test out these solutions in a fork, but will definitely need input from the community before a possible PR. |
We have a third-solution which is more of a workaround, but appears to be a quick change to our codebase that requires no PR for parse-server! Solution 3 This behaviour assumes that the internal code within Parse does not: Currently unknown - how this effects GraphQL. We'll tackle this later. |
Thanks @omairvaiyani for Solution 3. I already tried similar approach - to try / catch our cloudCode functions and put exception to Sentry directly, however I had problem that exception was not catch. Probably I did something wrong. Your re-throw approach is much better, because then error goes to logs as well. Could you please send example of simple cloudCode function that do this (Solution 3)? I would like to test this on our codebase, thanks! |
@sarsonj No problem glad our problem is also helping out yours. The proposed third solution does currently have a limitation in that parse-server is still sending the response back to the requesting client before sending the error to our middleware. This means that the Example usage for you: const requestWrapper = (requestHandler) => {
return async (request) => {
try {
const response = await requestHandler(request);
return response;
} catch (e) {
const parseError = new Parse.Error(e.code, e.message);
parseError._original = e;
throw parseError;
}
}
}
Parse.Cloud.define('foo', requestWrapper(fooHandler) );
Parse.Cloud.beforeSave('_User', requestWrapper(userBeforeSaveHandler) ); |
I believe your own workaround along with the suggestions I described in Solution 3 above are sufficient for now. Closing issue but for other contributors, there's probably some useful insights here to consider. |
Our app is heavily using cloud code. It is sometimes complex and there can be bugs.
However, currently it is difficult to get errors easily.
In logs, the stack trace is useless - it doesn't show, where the bug appears, like:
I don't care about
FunctionsRouter.js
, I want to get right place of error, that is currentlygetXmppServer.js
line4
. It would be nice to have correct stack trace in log.I also want to integrace Parse server with external tool, that collects app exeptions, like Sentry. Sentry have support for express.js, however, it doesn't currently catch Cloud Code exceptions. Is there any way to do this?
Is your feature request related to a problem? Please describe.
It is very difficult to debug Cloud Code bugs when we don't know, where the bug appear.
Describe the solution you'd like
Show correct file / line number where bug appears and allow to handle this bug by any express.js middleware.
The text was updated successfully, but these errors were encountered: