<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>7.1.1</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>All</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>6.1.4</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">When doing a request with <code class="notranslate">net</code> and the server responds with a status-code that signifies an error, the user can still read the response's body.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">It is impossible to read the reponse's body, as the response object emits a <code class="notranslate">net::ERR_HTTP_RESPONSE_CODE_FAILURE</code> error and stops.</p>
<h3 dir="auto">To Reproduce</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ git clone https://github.com/arantes555/electron-bug-net-body-when-error.git
$ npm install
$ npm start"><pre class="notranslate">$ git clone https://github.com/arantes555/electron-bug-net-body-when-error.git
$ npm install
$ npm start</pre></div>
<h3 dir="auto">Additional Information</h3>
<p dir="auto">This is a critical problem with <code class="notranslate">net</code>. In addition to making it impossible to implement <code class="notranslate">fetch</code> interface correctly, it simply makes <code class="notranslate">net</code> unsuitable for anything serious, as reading the body of the response (no matter the status-code) is at the core of what an HTTP request is.</p>
<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>7.1.1</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>Windows 10</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>Unknown</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">do not raise subsequent unhandled exception after response event received</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">Unhandled exception raised:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[Window Title]
Error

[Main Instruction]
A JavaScript error occurred in the main process

[Content]
Uncaught Exception:
Error: net::ERR_HTTP_RESPONSE_CODE_FAILURE

[OK]"><pre class="notranslate"><code class="notranslate">[Window Title]
Error

[Main Instruction]
A JavaScript error occurred in the main process

[Content]
Uncaught Exception:
Error: net::ERR_HTTP_RESPONSE_CODE_FAILURE

[OK]
</code></pre></div>
<h3 dir="auto">To Reproduce</h3>




<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/kwonoj/clientrequest-response-code-failure
npm install &amp;&amp; npm start"><pre class="notranslate"><code class="notranslate">git clone https://github.com/kwonoj/clientrequest-response-code-failure
npm install &amp;&amp; npm start
</code></pre></div>
<h3 dir="auto">Screenshots</h3>

<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1210596/68459094-410a6800-01b9-11ea-969b-3851c6b9b356.png"><img src="https://user-images.githubusercontent.com/1210596/68459094-410a6800-01b9-11ea-969b-3851c6b9b356.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Additional Information</h3>

<p dir="auto">Setting up <code class="notranslate">response</code> eventhandler correctly forwards 404 response, but right after unhandled exception is thrown. This is not caught by <code class="notranslate">error</code> eventhandler - regardless of setting up eventhandler or not, unhandled exception is always thrown.</p>