-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Azure.CoreClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Description
- Package Name:
@azure/communication-email - Package Version:
npm:1.1.0 - Operating system: macOS Tahoe 26.3 (N/A)
- nodejs
- version: N/A
- browser
- name/version: N/A
- typescript
- version:
npm:5.9.3
- version:
- Is the bug related to documentation in
- README.md
- source code documentation
- SDK API docs on https://learn.microsoft.com
Describe the bug
When running on Cloudflare Workers with nodejs_compat set per these instructions and like this:
const emailClient = new EmailClient(AZURE_ECS_CONNECTION_STRING);an unexpected error is thrown:
| Failed to run background task: Error: proxyPolicy is not supported in browser environment
<stack trace>
To Reproduce
Steps to reproduce the behavior:
- Set nodejs_compat in Cloudflare Wrangler:
"compatibility_flags": [
"nodejs_compat"
],
"compatibility_date": "2026-02-21",- Call
new EmailClient(...)from Cloudflare Workers
Expected behavior
The Azure SDK should not attempt to add the proxyPolicy to the fetch, and not throw an exception.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Use this temporary workaround:
- Create this file
workaround-azure-proxy.ts:
// workaround-azure-proxy.ts
/**
* The Azure SDK detects where it is running at the time of import.
* If the node_compat flag is set in wrangler, it will detect Cloudflare Workers as a Node.js runtime.
* This means that it will add a 'proxyPolicy' to the fetch pipeline, which isn't supported and throws an error.
*
* To avoid the error, this workaround needs to be imported right before @azure/communication-email.
* It works by masking `process.versions` from the platform detection logic.
*/
if (typeof process !== 'undefined' && process.versions) {
// Hide the Node version so Azure SDK thinks it is in a standard browser/worker env
Object.defineProperty(process.versions, 'node', {
value: undefined,
writable: true,
});
}- If your import looks like this:
import { EmailClient } from "@azure/communication-email";then replace it with (order is important):
import './workaround-azure-proxy';
import { EmailClient } from "@azure/communication-email";- In your
wrangler.jsonc, if it looks like this:
"compatibility_flags": [
"nodejs_compat"
],
"compatibility_date": "2026-02-21",then replace it like so (add disable_nodejs_process_v2 and no_nodejs_compat_v2):
"compatibility_flags": [
"nodejs_compat",
"disable_nodejs_process_v2",
"no_nodejs_compat_v2"
],
"compatibility_date": "2026-02-21",Not sure why the last step (3) is necessary to be honest, but it seems to be necessary.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Azure.CoreClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that