TypeError: Cannot read properties of undefined (reading 'Symbol(Body internals)')
See original GitHub issueReproduction
This works
const response = await fetch(`https://google.com/`);
await response.text();
while the syntatically equivalent
const {text} = await fetch(`https://google.com/`);
await text();
fails with TypeError: Cannot read properties of undefined (reading 'Symbol(Body internals)')
.
Expected behavior
Both code blocks should work as they are syntactically equivalent. It might be related to NodeJS primordials, see NodeJS Issue #36364.
Your Environment
software | version |
---|---|
node-fetch | 3.2.10 |
node | v18.9.0 |
npm | 8.19.1 |
Operating System | MacOS x64 |
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
Cannot make a node-fetch request, TypeError ... - GitHub
Cannot make a node-fetch request, TypeError: Cannot read property 'Symbol(requestOptions)' of undefined #36364.
Read more >Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >Why the error for Promise.all?: TypeError: Cannot read ...
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined.
Read more >How to Avoid the Infamous "Cannot read properties of ... - Bitovi
That error message is telling you the function is returning undefined implicitly, but its return type does not include undefined in it. Awesome!...
Read more >How to Fix TypeError: Cannot read Property 'push' of ...
You call the method on a variable previously set to undefined . · You call the method on a variable before it has...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the comprehensive response @jimmywarting - I learned a lot. Of course losing the binding context makes sense here, and the error as presented did’t immediately make sense, but after reading your notes, it’s perfectly understandable. Thanks also for the reading suggestions and thorough explanation through code snippets.
Worth reading https://www.aleksandrhovhannisyan.com/blog/overzealous-destructuring/