Skip to content

fix: Timeout on 500 when detail message is too large#809

Open
speeddragon wants to merge 4 commits intoneo/edgefrom
fix/500_timeout
Open

fix: Timeout on 500 when detail message is too large#809
speeddragon wants to merge 4 commits intoneo/edgefrom
fix/500_timeout

Conversation

@speeddragon
Copy link
Copy Markdown
Collaborator

@speeddragon speeddragon commented Mar 31, 2026

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.

},
NodeMsg
),
ErrorDetailsMaxSize = maps:get(error_details_max_size, NodeMsg, ?DEFAULT_ERROR_DETAILS_MAX_SIZE),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using the correct interface here? hb_opts

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)))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

false -> Elem ++ ", " ++ do_to_lines(Rest)
end.

truncate(Str, MaxSize) when is_list(Str) ->
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always a doc on at minimum public functions. Else, nobody will be able to find it.

%%% Tests

truncate_list_no_truncation_test() ->
?assertEqual("hello", truncate("hello", 10)).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants