QuickJS: fix error reporting in query server#5943
Open
Karthikeya1500 wants to merge 7 commits intoapache:mainfrom
Open
QuickJS: fix error reporting in query server#5943Karthikeya1500 wants to merge 7 commits intoapache:mainfrom
Karthikeya1500 wants to merge 7 commits intoapache:mainfrom
Conversation
If an unrecognized command is processed by globalThis.dispatch, the error handler attempts to reference cmdkey without it being defined. This throws a ReferenceError instead of generating the intended CouchDB fatal error array. This commit assigns cmd.shift() to a const variable cmdkey before evaluating the switch statement.
Use the errstr(e) utility in handleError to ensure meaningful error messages are returned to the client for both named and unnamed errors. - Replace e.stack with errstr(e) for unnamed errors - Replace raw Error object with errstr(e) for named errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
QuickJS: fix error reporting in query server
Problem
The QuickJS query server fails to report useful error messages when standard JavaScript errors or non-Error objects (like strings) are thrown outside of captured sandboxes.
JSON.stringify(e)results in an empty object{}. The client receives["error", "SomeError", {}]instead of the error details.throw "foo"): The server attempts to accesse.stack, which isundefinedon strings/primitives. This results in["error", "unnamed_error", null].Solution
Use the existing
errstr(e)utility (already defined inutil.js) to ensure that a descriptive string representation of the error is sent back to the client. This brings the QuickJS implementation in line with the SpiderMonkey behavior inloop.jsand other parts of the codebase.Testing
Verified that
errstr(e)correctly identifies and stringifies both standardErrorinstances and primitive values thrown by user code.