-
Notifications
You must be signed in to change notification settings - Fork 4
Properly display non-Polykey errors instead of printing undefined
#320
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
Conversation
A separate test is needed to ensure keeping the secrets edit open for around 60 seconds should not cause a websocket connection error. Something like this can be used: test(
'timed test',
async () => {
// launch the editor
// sleep for 60 seconds
// close the editor
},
timeout=70000
); |
We want to avoid using sleeps in tests generally now. #38 If you can, use promises to wait for the timeout to happen before proceeding. |
Well the sleep won't be in the actual TS test. Instead, the sleep will be inside the command which will be executed by the command as the Is this also troublesome, or would this be fine? |
Its better if we don't. Just have the editor scrip wait for an input on stdin. We can use that as a semaphore for the next step and then control timing from the test. Also look into using |
Never rely on sleep. It's non-deterministic. |
Currently, I am wrapping any unexpected errors in This is the only real major change being done, so once this is addressed, then we should be able to get this merged pretty quickly. |
Currently, the errors look like this. The code for determining the cause string was taken from MatrixAI/js-rpc#69. This is what the undefined errors would look like now. Note that for testing, I am inducing an undefined error as such:
|
Why do we need a |
I have done this to be consistent and clear. If we throw an error like With the prefix, it is much clearer:
and
|
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.
Just some key points I wanted to mention.
d1d06cf
to
1ba6b52
Compare
feat: fixed websocket timeout with long running edit sessions chore: added proper erroring to edit command chore: updating error rendering chore: cleaned up error rendering chore: updated handlers and tests to match polykey fix: render all ErrorPolykeyCLI instead of just the unexpected errors deps: updated polykey chore: reduced usage of the as keyword chore: added error details and stack to unexpected error message fix: removed stack trace for errors fix: throwing standard errors unexpectedly
1ba6b52
to
8685257
Compare
All the tasks have been completed and the CI is also passing. Merging as completed. |
Remember errors have the name, description and message. The message is instance context while description is static. |
Description
In Polykey, any non-Polykey errors get serialised as raw JSON, and are not able to be properly converted back into the original errors, or be printed on the output.
The only output we get if a non-Polykey error propagates through is
undefined
in the output with a non-zero exit code.This PR should combat this by wrapping it in
ErrorPolykeyCLIUnexpectedError
, then rendering that error instead. In the future, this should help with identifying exactly what went wrong by providing more context instead of printing a uselessundefined
as the error message.As #315 is a quick fix, I will make that change here too.
Issues Fixed
secrets
commands throw anundefined
error #311 (REF ENG-434)secrets edit
should maintain the websocket as long as the editor session is alive #315 (REF ENG-440)Tasks
exec
async)Final checklist