bugfix: display proper error message when surrealdb responds with an error #249
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 ofCBORError: Remaining bytes
Have you read the Contributing Guidelines?