Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser] fix NodeJS fetch detection #89393

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))]
pavelsavara marked this conversation as resolved.
Show resolved Hide resolved
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
Loading