Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: node-fetch/node-fetch
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.6.11
Choose a base ref
...
head repository: node-fetch/node-fetch
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.6.12
Choose a head ref
  • 1 commit
  • 1 file changed
  • 3 contributors

Commits on Jun 29, 2023

  1. fix: socket variable testing for undefined (#1726)

    * fix: socket variable testing for undefined
    Avoid issue where socket event was not triggered and local socket vraible is not defined.
    This issue is reproducible only using deno.
    
    * chore: made socket test capture simpler
    Only controls the execution of the section that uses socket.
    
    * Update src/index.js
    
    Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
    
    * Update index.js
    
    ---------
    
    Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
    Co-authored-by: Jimmy Wärting <jimmy@warting.se>
    3 people authored Jun 29, 2023
    Copy the full SHA
    8bc3a7c View commit details
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/index.js
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -362,8 +362,11 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
const {headers} = response;
if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) {
response.once('close', hadError => {
// if a data listener is still present we didn't end cleanly
const hasDataListener = socket.listenerCount('data') > 0;
// tests for socket presence, as in some situations the
// the 'socket' event is not triggered for the request
// (happens in deno), avoids `TypeError`
// if a data listener is still present we didn't end cleanly
const hasDataListener = socket && socket.listenerCount('data') > 0;

if (hasDataListener && !hadError) {
const err = new Error('Premature close');