Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.07k stars 1.2k forks source link

[CosmosDB] Force fetch instead of NodeHttpClient #23026

Closed isaac-mcfadyen closed 3 months ago

isaac-mcfadyen commented 2 years ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

xirzec commented 2 years ago

Exposing passing a custom HttpClient seems like the right thing here, since there are various reasons why consumers may wish to switch out the transport.

danny-people-plus commented 1 year ago

Exposing passing a custom HttpClient seems like the right thing here, since there are various reasons why consumers may wish to switch out the transport.

Agree, we would love to be able to use cosmos with our Cloudflare Workers project. Currently considering https://fauna.com/ if anyone is looking for alternatives.

Anything we can do to help?

ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @bkolant-MSFT, @sajeetharan, @pjohari-ms.

Issue Details
**Is your feature request related to a problem? Please describe.** - Environments such as [Cloudflare Workers](https://workers.cloudflare.com/) can communicate over HTTP but don't support Node modules such as `http` and use a [built-in `fetch`](https://developers.cloudflare.com/workers/runtime-apis/fetch/) instead, similar to browsers. - However, when installing `@azure/cosmos` NodeHttpClient is used by default (and looks to be hardcoded in, according to `createDefaultHttpClient` from `core-rest-pipeline`) which causes CosmosDB calls to fail. **Describe the solution you'd like** - A way to force `@azure/cosmos` to use `fetch` via a config option or similar (such as `httpClient` in `CosmosClientOptions`). **Describe alternatives you've considered** - Modifying the source to choose automatically, as it doesn't seem to currently (or the heuristics for such a decision aren't working). - Using an alternative client made specifically for Cloudflare Workers such as `@cfworker/cosmos`. However, this client doesn't support all features (most notably Partial Document Updates). **Additional context** - There seemed to be a PR to address this but it didn't get completed for CosmosDB: https://github.com/Azure/azure-sdk-for-js/issues/16876
Author: isaac-mcfadyen
Assignees: sajeetharan
Labels: `question`, `customer-reported`, `Client`, `Cosmos`, `Service Attention`, `feature-request`
Milestone: -
danny-people-plus commented 1 year ago

@xirzec which milestone do we think could resolve this issue?

xirzec commented 1 year ago

@xirzec which milestone do we think could resolve this issue?

That's up to @sajeetharan as the package owner.

sajeetharan commented 1 year ago

Thanks @xirzec

@danny-people-plus we are working on this, tentative ETA is August 2023

VicSmithVercel commented 1 year ago

Excited to see this on the roadmap. Thanks @isaac-mcfadyen for starting this issue.

danny-people-plus commented 1 year ago

Thanks @xirzec

@danny-people-plus we are working on this, tentative ETA is August 2023

I can see that this is still an issue, any update or revised timescale?

Cheers

danny-people-plus commented 11 months ago

I can see that this is still an issue and the fix has been removed from the 2023-11 milestone, any update or revised timescale?

danny-people-plus commented 10 months ago

@xirzec @sajeetharan any update on this? Any chance of a Christmas miracle this year?

xirzec commented 10 months ago

@xirzec @sajeetharan any update on this? Any chance of a Christmas miracle this year?

I'm not sure if it counts as a miracle, but I threw together a quick PR for you: https://github.com/Azure/azure-sdk-for-js/pull/28080