Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fetch with URL object fails with Cannot read properties of undefined (reading 'has') #648

Open
borgoat opened this issue May 14, 2024 · 1 comment

Comments

@borgoat
Copy link

borgoat commented May 14, 2024

We are using fetch passing a URL object as resource parameter - and a second options argument containing headers. The first parameter may be any object with a stringifier.1

However, currently it implies here2 that any object passed as first argument to fetch must be a Request.

TypeError: Cannot read properties of undefined (reading 'has')\n    at o9.fetch (/node_modules/.pnpm/aws-xray-sdk-fetch@3.6.0_aws-xray-sdk-core@3.6.0/node_modules/aws-xray-sdk-fetch/lib/fetch_p.js:71:25)\n    at o9.getData (/libs/instruments/service-cityfalcon/src/lib/cityfalcon.service.ts:179:12)\n    at params (/libs/instruments/service-cityfalcon/src/lib/cityfalcon.service.ts:60:14)\n    at Array.map (<anonymous>)\n    at o9.getMarketNewsTimeline (/libs/instruments/service-cityfalcon/src/lib/cityfalcon.service.ts:59:18)\n    at mWe (/libs/instruments/cloud/src/lib/market-news/market-news.get-market-news.fn/index.ts:103:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at gfe (/node_modules/.pnpm/@middy+core@4.7.0/node_modules/@middy/core/index.js:120:32)

Footnotes

  1. https://developer.mozilla.org/en-US/docs/Web/API/fetch

  2. https://github.com/aws/aws-xray-sdk-node/blob/58dd586b2e1de562dce07c74e0d066d2b74ad210/sdk_contrib/fetch/lib/fetch_p.js#L63C11-L65

@rslfilho
Copy link

Im having the same issue here, was using a URL object as first parameter for fetch, and encounter the same error. Not every time the first parameter is a object, it will be a Request. For now i updated my code to send the URL.href string as resource, but should be fixed

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants