fix: Timeout on 500 when detail message is too large#809
Open
speeddragon wants to merge 4 commits intoneo/edgefrom
Open
fix: Timeout on 500 when detail message is too large#809speeddragon wants to merge 4 commits intoneo/edgefrom
speeddragon wants to merge 4 commits intoneo/edgefrom
Conversation
src/hb_http_server.erl
Outdated
| }, | ||
| NodeMsg | ||
| ), | ||
| ErrorDetailsMaxSize = maps:get(error_details_max_size, NodeMsg, ?DEFAULT_ERROR_DETAILS_MAX_SIZE), |
Collaborator
There was a problem hiding this comment.
Why not using the correct interface here? hb_opts
src/hb_http_server.erl
Outdated
| ErrorMsg#{ | ||
| <<"stacktrace">> => hb_util:bin(hb_format:remove_noise(StacktraceStr)), | ||
| <<"details">> => hb_util:bin(hb_format:remove_noise(DetailsStr)) | ||
| <<"details">> => binary:part(DetailsBin, 0, min(ErrorDetailsMaxSize, byte_size(DetailsBin))) |
Collaborator
There was a problem hiding this comment.
Please do the normal truncation flow: Check if it is over the cap and add ... after truncating if so. This almost certainly already exists in hb_format or hb_util. If not, we should add it.
src/hb_format.erl
Outdated
| false -> Elem ++ ", " ++ do_to_lines(Rest) | ||
| end. | ||
|
|
||
| truncate(Str, MaxSize) when is_list(Str) -> |
Collaborator
There was a problem hiding this comment.
Always a doc on at minimum public functions. Else, nobody will be able to find it.
src/hb_format.erl
Outdated
| %%% Tests | ||
|
|
||
| truncate_list_no_truncation_test() -> | ||
| ?assertEqual("hello", truncate("hello", 10)). |
Collaborator
There was a problem hiding this comment.
Any particular reason for the list compatibility? We have tried to standardize the whole codebase on 'strings are binaries' to minimize type confusion. If there isn't a particular purpose, let's remove it.
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.
In some cases, for example, ANS104 invalid signature, the details contained a large binary (1MB). Trying to send it over the socket would consume too many resources.
The default value now is 32KB, which can be changed using
error_details_max_size.