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

Any type of connection fails when using with next.js. #350

Closed
titong0 opened this issue Mar 11, 2023 · 5 comments
Closed

Any type of connection fails when using with next.js. #350

titong0 opened this issue Mar 11, 2023 · 5 comments

Comments

@titong0
Copy link
Contributor

titong0 commented Mar 11, 2023

After updating to V3.3.0, I'm getting multiple crashes for any code that uses the library, even

const youtube = Innertube.create();

The error I'm getting looks like this:

error - unhandledRejection: TypeError: First parameter has member 'readable' that is not a ReadableStream.
    at Y (C:...\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:234:11)
    at C:\..\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:1775:50
    at ReadableStream.pipeThrough (C:...\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:1778:6)
    at fetchFinale (C:...\node_modules\undici\lib\fetch\index.js:973:52)
    at mainFetch (C:...\node_modules\undici\lib\fetch\index.js:773:5)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I don't know wether this is a next.js thing but it wasn't happening before updating to 3.3.0.

Originally posted by @titong0 in #279 (comment)

@LuanRT
Copy link
Owner

LuanRT commented Mar 12, 2023

I'm not familiar with Next.js so I can't tell. I've done a few tests and the latest version does work with other web frameworks such as Vue or even pure JavaScript + HTML though, so it is probably unrelated to the library.

And speaking of which, what do your imports look like?

See (taken from the documentation):

// Unbundled ESM version
import { Innertube } from 'youtubei.js/web';
// Bundled ESM version
import { Innertube } from 'youtubei.js/web.bundle';
// Production Bundled ESM version
import { Innertube } from 'youtubei.js/web.bundle.min';

@titong0
Copy link
Contributor Author

titong0 commented Mar 12, 2023

I'm importing like this

import { Innertube } from "youtubei.js";

Is there any documentation about the different imports? When should I use one or the other?

@absidue
Copy link
Collaborator

absidue commented Mar 12, 2023

@titong0 if next.js is anything like webpack, it's picking the node.js import instead of the web one, despite the output target being a web browser, so you can use one of the 3 above to force it to use a web one.

@titong0
Copy link
Contributor Author

titong0 commented Mar 12, 2023

The problem is, nextjs runs on both server and client. In my case its only running on the server so I think a node.js version would actually be ideal?

@titong0
Copy link
Contributor Author

titong0 commented Mar 12, 2023

In case this happened to anyone. Running npm update seemed to solve things. Don't know what happened though. Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants