Skip to content

Commit

Permalink
Fixing GraphQL SSE crash with large stanza payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
JanuszJakubiec committed Aug 23, 2024
1 parent 344108f commit 32151fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions big_tests/tests/graphql_sse_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ sse_should_not_get_timeout(Config) ->
timer:sleep(2000),
escalus:send(Bob, escalus_stanza:chat(From, To, <<"Hello again!">>)),
sse_helper:wait_for_event(Stream),
timer:sleep(2000),
Message = binary:copy(<<"0">>, 2000),
escalus:send(Bob, escalus_stanza:chat(From, To, Message)),
sse_helper:wait_for_event(Stream),
sse_helper:stop_sse(Stream)
end).

Expand Down
4 changes: 2 additions & 2 deletions src/graphql/mongoose_graphql_response.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
-export([term_to_json/1, term_to_pretty_json/1]).

term_to_json(Term) ->
jiffy:encode(fixup(Term)).
iolist_to_binary(jiffy:encode(fixup(Term))).

Check warning on line 6 in src/graphql/mongoose_graphql_response.erl

View check run for this annotation

Codecov / codecov/patch

src/graphql/mongoose_graphql_response.erl#L6

Added line #L6 was not covered by tests

term_to_pretty_json(Term) ->
jiffy:encode(fixup(Term), [pretty]).
iolist_to_binary(jiffy:encode(fixup(Term), [pretty])).

%% Ground types
fixup(Term) when is_number(Term) -> Term;
Expand Down

0 comments on commit 32151fb

Please sign in to comment.