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

bugfix: display proper error message when surrealdb responds with an error #249

Merged
merged 3 commits into from
May 7, 2024

Conversation

SamuelScheit
Copy link
Contributor

@SamuelScheit SamuelScheit commented Apr 28, 2024

What is the motivation?

I was trying to insert a lot of objects and got a the error message "CBORError: Remaining bytes", which I first couldn't understand.
I've traced it back to the engine.ts file and the decodeCbor function and fixed the error message by displaying the response string, which has more meaningful information about the error.

image

What does this change do?

I've improved the error message by catching any errors thrown by the decodeCbor function and displaying the buffer that is trying to be decoded as an error string.

What is your testing strategy?

I've setup surrealdb.js with the patch and tried to insert 100k objects with .insert().
The operation fails with the following error Failed to buffer the request body: length limit exceeded instead of CBORError: Remaining bytes

Have you read the Contributing Guidelines?

@kearfy
Copy link
Member

kearfy commented May 6, 2024

Hey @SamuelScheit, thank you for this! There are two issues with the current implementation:

  • You throw a generic Error. In this library we only throw errors extending a base SurrealDbError class to make it easier for implementors to catch where errors come from.
  • Buffer is not available in all major runtimes, taking browsers as an example.

I'll see how I can resolve these issues and push those fixes to your branch, unless you'd like to pick them up 😃

@SamuelScheit
Copy link
Contributor Author

@kearfy thank you, you can contribute to my branch 👍

@kearfy kearfy merged commit 23a3cfc into surrealdb:main May 7, 2024
@kearfy
Copy link
Member

kearfy commented May 7, 2024

I had to change it up a bit but HTTP Connection errors should now be properly handled. Thanks for opening this!

@kearfy kearfy mentioned this pull request May 7, 2024
2 tasks
@rvdende
Copy link

rvdende commented May 7, 2024

@kearfy will you bump the version and release a npm build version perhaps so we can easily upgrade?

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

Successfully merging this pull request may close these issues.

None yet

3 participants