Skip to content

Crashes in httpc_handler #10368

@itssundeep

Description

@itssundeep

Describe the bug
We see crashes in httpc_handler for connections which are upgraded from http -> https. We notice that once a http connection is established, upgrading the connection to https, drops request_options from the original request. This results in gen_server crashes if the connection has issues and we answer back on these connections.

Example Crash

2025-11-10T13:53:39.886518-08:00 <0.124847.0> otp.log gen_server.erl:2785 == 
error: Generic server <0.124847.0> terminating. 
Label: {http,<<"someserver">>,443}. 
Reason: {
    function_clause,[{proplists,get_value,[full_result,undefined,true],[{file,"proplists.erl"},{line,222}]},
{httpc_handler,format_answer,2,[{file,"httpc_handler.erl"},{line,1744}]},
{httpc_handler,answer_request,3,[{file,"httpc_handler.erl"},{line,1348}]},
{httpc_handler,terminate,2,[{file,"httpc_handler.erl"},{line,327}]},
{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,2482}]},
{gen_server,terminate,9,[{file,"gen_server.erl"},{line,2733}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,333}]}]}. 
Last message: 
{init_error,error_connecting,
{#Ref<0.551509106.3093299207.219206>,
{error,
{failed_connect,[{to_address,{"someserver",443}},{inet6,[inet6,{send_timeout,3000},{send_timeout_close,true}],nxdomain}]}}}}.

2025-11-10T13:55:30.376431-08:00 <0.117.0> service.log supervisor.erl:1374 == error: 
Supervisor: {local,httpc_handler_sup}. 
Context: child_terminated. Reason: 
{function_clause,[{proplists,get_value,[full_result,undefined,true],[{file,"proplists.erl"},{line,222}]},
{httpc_handler,format_answer,2,[{file,"httpc_handler.erl"},{line,1744}]},
{httpc_handler,answer_request,3,[{file,"httpc_handler.erl"},{line,1348}]},
{httpc_handler,terminate,2,[{file,"httpc_handler.erl"},{line,327}]},
{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,2482}]},
{gen_server,terminate,9,[{file,"gen_server.erl"},{line,2733}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,333}]}]}. Offender: id=undefined,pid=<0.238357.0>.

This issue is introduced due to PR 299be8d

To Reproduce
Not sure how to simulate error on an established connection

Expected behavior
We should not crash

Affected versions
OTP 28

Additional context

Metadata

Metadata

Assignees

Labels

bugIssue is reported as a bugteam:PSAssigned to OTP team PS

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions