You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the snippet provided in the code to reproduce section fails.
got tries to mutate the options object. This currently impacts test scenarii where the same options object is used between different tests.
Actual behavior
> node .
(node:12424) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'body' of undefined
at /home/user/dev/got-issue/index.js:12:32
(node:12424) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:12424) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Expected behavior
No mutation.
Code to reproduce
constgot=require('got');constoptions={};Object.freeze(options);(async()=>{try{constresponse=awaitgot('https://sindresorhus.com',options);console.log(response.body);//=> '<!doctype html> ...'}catch(error){console.log(error.response.body);//=> 'Internal server error ...'}})();
Checklist
I have read the documentation.
I have tried my code with the latest version of Node.js and Got.
The text was updated successfully, but these errors were encountered:
szmarczak
changed the title
got should not mutate options
Got throws if passed options are already frozen
Feb 6, 2020
Describe the bug
path
andquery
options #86~16.04.1-Ubuntu SMP Mon Jan 20 11:02:50 UTC 2020 x86_64 x86_64 x86_64 GNU/LinuxCurrently the snippet provided in the
code to reproduce
section fails.got
tries to mutate theoptions
object. This currently impacts test scenarii where the sameoptions
object is used between different tests.Actual behavior
Expected behavior
No mutation.
Code to reproduce
Checklist
The text was updated successfully, but these errors were encountered: