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

error: failed to construct 'Request': the 'duplex' member must be specified for a request with a streaming body #816

Open
4 tasks done
sayaa10 opened this issue Nov 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sayaa10
Copy link

sayaa10 commented Nov 22, 2024

Steps to reproduce

const createEnhancedFetch = (timeout = 10000) => {
return async (input, init) => {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeout);

try {
  const url =
    typeof input === "string"
      ? new URL(input)
      : input instanceof URL
      ? input
      : new URL(input.url);

  url.searchParams.set("__host", url.host);
  url.host = "192.168.18.10:8080";
  url.protocol = "http";

  const headers = init?.headers
    ? new Headers(init.headers)
    : input instanceof Request
    ? input.headers
    : new Headers();

  url.searchParams.set("__headers", JSON.stringify([...headers]));

  const request = new Request(
    url,
    input instanceof Request ? input : undefined
  );
  headers.delete("user-agent");

  const response = await fetch(request, {
    ...(init || {}),
    headers,
    signal: controller.signal,
  });

  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  }

  return response;
} finally {
  clearTimeout(timeoutId);
}

};
};

// Initialize YouTube client
const initializeYouTubeClient = async () => {
return await Innertube.create({
fetch: createEnhancedFetch(),
generate_session_locally: true,
cache: new UniversalCache(true),
});
};

Failure Logs

this works in my browser but inside android webview and in some browsers like bing for android  I get this error: failed to construct 'Request': the 'duplex' member must be specified for a request with a streaming body

I tried setting duplex half and that didn't work too I got some other errors

Expected behavior

Expected to inatialize the youtube client

Current behavior

The issue is still the same I tried fixing it for several hours happens only in android webview

Version

Edge

Anything else?

No response

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.
@sayaa10 sayaa10 added the bug Something isn't working label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant