Skip to content

Commit

Permalink
fix NodeJS fetch detection (#89393)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed Jul 25, 2023
1 parent 6679062 commit 1bfd46d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/runtime/loader/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response> {
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) {
Expand Down

0 comments on commit 1bfd46d

Please sign in to comment.