Skip to content

error object lost in SchemasRouter #4871

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

Closed
oallouch opened this issue Jul 4, 2018 · 7 comments
Closed

error object lost in SchemasRouter #4871

oallouch opened this issue Jul 4, 2018 · 7 comments

Comments

@oallouch
Copy link
Contributor

oallouch commented Jul 4, 2018

Hi,
I got a "Database adapter error" from SchemasRouter, but the original error gets eaten by:

.catch(error => { if (error === undefined) { throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME,Class ${className} does not exist.); } else { throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'Database adapter error.'); } });

Should the original message be appended ?
Should Parse.Error have another constructor argument (sourceError) ?
Should the original error be rethrown ?

Thx a lot (as always),

Olivier

@flovilmart
Copy link
Contributor

Is it a recurring error / are you able to reproduce it?

@oallouch
Copy link
Contributor Author

oallouch commented Jul 4, 2018

Yes.
Actually, it was thrown in MongoStorageAdapter.deleteObjectsByQuery(). Debugging handleError(error) gave me the error message : "Cannot use (or request) retryable writes with limit=0"
I recently moved to MongoDB Atlas and I apparently need to remove retryWrites=true from my connection URI.
see https://stackoverflow.com/questions/50283081/mongodb-error-cannot-use-retryable-writes-with-limit-0
They say it's better to change some queries.

Anyway, having the original message appended in the Parse.Error would be nice, I think.

@flovilmart
Copy link
Contributor

Feel free to open a PR, I'd rather have the error logged as is with the logger, the error is forwarded to the client and it's leaky to forward database level errros in public :)

@oallouch
Copy link
Contributor Author

oallouch commented Jul 4, 2018

Can it be something like:

  handleError<T>(error: ?(Error | Parse.Error)): Promise<T> {
    if (error && error.code === 13) { // Unauthorized error
      delete this.client;
      delete this.database;
      delete this.connectionPromise;
      logger.error('Received unauthorized error', { error: error });
    } else {
     logger.error('Unknown MongoDB error', { error: error });
    }
    throw error;
  }

@flovilmart
Copy link
Contributor

at handle error level, I believe it’s already too late and the Db error may already be swallowed, but I may be wrong :) try it out :p

@oallouch
Copy link
Contributor Author

oallouch commented Jul 6, 2018

the debug session tells me it's ok

@stale
Copy link

stale bot commented Nov 2, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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