question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read properties of null (reading 'body') after update from 3.2.4 to 3.2.5 on 302 status code

See original GitHub issue

Reproduction

Steps to reproduce the behavior:

import fetch from 'node-fetch';

fetch('URL which returns 302 code')
    .then((response) => response.text())
    .then(console.log)
    .catch(console.error);
file:///C:/Git/monitoring_bot/node_modules/node-fetch/src/index.js:113
                        response.body.destroy(error);
                                 ^

TypeError: Cannot read properties of null (reading 'body')
    at file:///C:/Git/monitoring_bot/node_modules/node-fetch/src/index.js:113:13
    at TLSSocket.onSocketClose (file:///C:/Git/monitoring_bot/node_modules/node-fetch/src/index.js:386:5)
    at TLSSocket.emit (node:events:539:35)
    at node:net:715:12
    at TCP.done (node:_tls_wrap:582:7)

Node.js v17.9.0

Expected behavior

Don’t throw error, follow redirect and print response.text()

Your Environment

software version
node-fetch 3.2.5
node 17.9.0
npm 8.5.0
Operating System windows and linux

Additional context

Problem exists after update to 3.2.5, on 3.2.4 example code doesn’t throw error

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
jimmywartingcommented, Jun 9, 2022

#1578 was just released, could you try the newest version?

0reactions
jimmywartingcommented, Jun 11, 2022

good, closing this then

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read properties of null (reading 'user')
The error clearly say what's going wrong. It is because your initial value of user is null . That's why when you do...
Read more >
cannot read properties of null (reading 'body') - You.com
node-fetch/node-fetchTypeError: Cannot read properties of null (reading 'body') after update from 3.2.4 to 3.2.5 on 302 status code#1574.
Read more >
How To Fix the HTTP 302 Error (5 Methods) - Kinsta
HTTP 302 codes are useful to temporarily redirect website users to another URL. If you're getting this error code, here are 5 ways...
Read more >
S3Exception: null (Service: S3, Status Code: 302 ) · Issue #3104
To debug the issue, I have written a test standalone application (AwsReadAllObjects. java) using the same code as the application.
Read more >
3216341-33.patch - Drupal
if (selector === null) { - elements = []; - } - // The selector is undefined, error out. - else if (!selector)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found