diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs index bb9441ae7c5155..746feb41711cac 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs @@ -584,7 +584,7 @@ public HttpMetricsTest_Http11(ITestOutputHelper output) : base(output) { } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNodeJS))] public async Task RequestDuration_EnrichmentHandler_ContentLengthError_Recorded() { await LoopbackServerFactory.CreateClientAndServerAsync(async uri => diff --git a/src/mono/wasm/runtime/loader/polyfills.ts b/src/mono/wasm/runtime/loader/polyfills.ts index d77ceabc0b79a6..f9aae41f469a56 100644 --- a/src/mono/wasm/runtime/loader/polyfills.ts +++ b/src/mono/wasm/runtime/loader/polyfills.ts @@ -81,9 +81,10 @@ export async function detect_features_and_polyfill(module: DotnetModuleInternal) } } -const hasFetch = typeof (globalThis.fetch) === "function"; export async function fetch_like(url: string, init?: RequestInit): Promise { try { + // this need to be detected only after we import node modules in onConfigLoaded + const hasFetch = typeof (globalThis.fetch) === "function"; if (ENVIRONMENT_IS_NODE) { const isFileUrl = url.startsWith("file://"); if (!isFileUrl && hasFetch) {