sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.27k stars 935 forks source link

Cannot set property ip of #<IncomingMessage> which has only a getter #1157

Closed trendchaser4u closed 4 years ago

trendchaser4u commented 4 years ago

Describe the bug

Actual behavior

Executing the below code should console response body

(async () => {
    try {
      const response = await got('https://sindresorhus.com');
      console.log(response.body);
      //=> '<!doctype html> ...'
    } catch (error) {
      console.log(error);
      //=> 'Internal server error ...'
    }
  })();

...

Expected behavior

But throwing below error

image

...

Code to reproduce

const got = require('got');

(async () => {
    try {
      const response = await got('https://sindresorhus.com');
      console.log(response.body);
      //=> '<!doctype html> ...'
    } catch (error) {
      console.log(error);
      //=> 'Internal server error ...'
    }
  })();

Checklist

sindresorhus commented 4 years ago

Can you update your Node.js version to the latest v10.x version? To rule out it’s not an already fixed Node.js issue.

szmarczak commented 4 years ago

Also please try out the newest Got release (11.0.0-beta.1).

trendchaser4u commented 4 years ago

Can you update your Node.js version to the latest v10.x version? To rule out it’s not an already fixed Node.js issue.

yes, I've updated the node version, still, error occurs. This type of error will come only in strict mode.

image

if I comment "use strict" it is working fine.

image

Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only

trendchaser4u commented 4 years ago

Also please try out the newest Got release (11.0.0-beta.1).

Sure will try this version and let you know the result. :)

Update:

Issue resolved in 11.0.0-beta.1 release.

szmarczak commented 4 years ago

Glad to hear this. You must've used a custom IncomingMessage instance since Node.js doesn't define the ip property.