-
Notifications
You must be signed in to change notification settings - Fork 22
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
#6408: jq error handling improvements #6415
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #6415 +/- ##
==========================================
- Coverage 70.08% 70.08% -0.01%
==========================================
Files 1167 1167
Lines 36403 36431 +28
Branches 6852 6860 +8
==========================================
+ Hits 25512 25531 +19
- Misses 10891 10900 +9
☔ View full report in Codecov by Sentry. |
src/bricks/util.ts
Outdated
} | ||
|
||
if ( | ||
(retryError && !error.message.includes(retryError)) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to compare errors in javascript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on the error, e.g., depending on the error you might look at the class name. In this case, we do want to compare on the messages.
See comment here: https://github.com/pixiebrix/pixiebrix-extension/pull/6415/files#r1320839837
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this particular scenario, I think want the retry to happen on both on the generic error, and also unexpected end of JSON error. I suspect some of the unexpected end of JSON errors are transient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
src/bricks/util.ts
Outdated
retryError?: string | ||
): Promise<T> { | ||
for (let failedAttempts = 0; failedAttempts <= retries; failedAttempts++) { | ||
const delayMs = Math.random() * 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to adjust this number as needed. I didn't choose this number for any particular reason, other than the fact that it seemed like a good ballpark number.
src/bricks/transformers/jq.ts
Outdated
3, | ||
(error) => { | ||
if (!isErrorObject(error)) { | ||
throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shouldRetry method should not throw. The check should be isErrorObject(error) && (....)
src/bricks/transformers/jq.ts
Outdated
} | ||
|
||
return ( | ||
error.message.includes(JSON_ERROR) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a comment that we're not retrying on FS_STREAM_ERROR because it's not recoverable. The error kicks in when the jq brick has been run too many times, so retrying won't succeed
…ix-extension into feature/6408-jq-errors
src/bricks/transformers/jq.ts
Outdated
* Return true for jq errors that might be transient. | ||
* | ||
* We're excluding FS_STREAM_ERROR because it most likely indicated emscripten has hit the stream limit, so additional | ||
* retries would not success: https://github.com/fiatjaf/jq-web/issues/18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* retries would not success: https://github.com/fiatjaf/jq-web/issues/18 | |
* retries would not succeed: https://github.com/fiatjaf/jq-web/issues/18 |
src/bricks/transformers/jq.ts
Outdated
/** | ||
* Return true for jq errors that might be transient. | ||
* | ||
* We're excluding FS_STREAM_ERROR because it most likely indicated emscripten has hit the stream limit, so additional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* We're excluding FS_STREAM_ERROR because it most likely indicated emscripten has hit the stream limit, so additional | |
* We're excluding FS_STREAM_ERROR because it most likely indicates emscripten has hit the stream limit, so additional |
* | ||
* JSON_ERROR can be deterministic, but we've also seen some error telemetry indicating it might be transient. | ||
*/ | ||
function isTransientError(error: unknown): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactor is a huge improvement 👍
No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack. Do not edit this comment manually. |
What does this PR do?
Work remaining
generic error, no stack
Discussion
generic error, no stack
error with jq is transient, we might consider automatically retrying it<generic error, no stack>
exception using jq.promised.json fiatjaf/jq-web#31Unexpected end of JSON input
fromjq.promised.json
if no result set produced fiatjaf/jq-web#32Future Work
Checklist