Skip to content

Commit 1bfd46d

Browse files
authored
fix NodeJS fetch detection (#89393)
1 parent 6679062 commit 1bfd46d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ public HttpMetricsTest_Http11(ITestOutputHelper output) : base(output)
584584
{
585585
}
586586

587-
[Fact]
587+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNodeJS))]
588588
public async Task RequestDuration_EnrichmentHandler_ContentLengthError_Recorded()
589589
{
590590
await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>

src/mono/wasm/runtime/loader/polyfills.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ export async function detect_features_and_polyfill(module: DotnetModuleInternal)
8181
}
8282
}
8383

84-
const hasFetch = typeof (globalThis.fetch) === "function";
8584
export async function fetch_like(url: string, init?: RequestInit): Promise<Response> {
8685
try {
86+
// this need to be detected only after we import node modules in onConfigLoaded
87+
const hasFetch = typeof (globalThis.fetch) === "function";
8788
if (ENVIRONMENT_IS_NODE) {
8889
const isFileUrl = url.startsWith("file://");
8990
if (!isFileUrl && hasFetch) {

0 commit comments

Comments
 (0)