Fix monster error stack #216
Merged
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.
This was a tricky one. The problem is a combination of
gotincludes a lot of metadata properties on their errors, likerequest,response,timingsetc,vitestlogs an error, they take all of the properties on the error object and deeply serialize it, and there's no easy way to disable this behavior.Vitest issues:
Example:
Because imo this is mostly a problem with vitest, and from the previous 2 issues it doesn't seem like the vitest team wants to change this behaviour, the workaround is to wrap the Transloadit object (when running tests) in a Proxy that will catch-rethrow all errors with a toJSON on all the properties that we don't want to expose in the vitest error serialization. this makes sure Transloadit error API doesn't change, and people can still access properties like
err.response.body.I think in a future major of our SDK we should probably make our own opaque error abstraction that wraps all got (http request) specific errors, instead of passing them through (which we do now). This will also probably avoid this
vitestproblem, unless we decide to still expose stuff like HTTP response bodies in our errors.kind of related: sindresorhus/got#1126