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

TypeError [ERR_INVALID_ARG_TYPE]: The "stream" argument must be an instance of Stream. Received an instance of ReadableStream, following a dump of a JavaScript file #48

Open
Toidi357 opened this issue Dec 25, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Toidi357
Copy link

Describe the bug

Simply running this code

const { YtdlCore } = require("@ybd-project/ytdl-core") 
const ytdl = new YtdlCore({ logDisplay: ['info', 'success', 'error', 'debug'] })

gets a TypeError [ERR_INVALID_ARG_TYPE]: The "stream" argument must be an instance of Stream. Received an instance of ReadableStream error. I've cleared the .CacheFiles and tried regenerating new OAuth credentials. This code actually works just fine on my local machine, but my guess is that my other machine is IP blocked and so this is the error message for that. Since it looks like OAuth might not work to circumvent blocks anymore (see here and here ), are there currently any ways to circumvent blocking?



[  DEBUG  ]: [ Request ]: GET -> https://www.youtube.com/iframe_api
[  DEBUG  ]: [ FileCache ]: "poToken" is cached.
[  DEBUG  ]: [ FileCache ]: "visitorData" is cached.
[  DEBUG  ]: Since PoToken and VisitorData are not specified, they are generated automatically.
[  DEBUG  ]: [ FileCache ]: "poToken" is cached.
[  DEBUG  ]: [ FileCache ]: "visitorData" is cached.
[  DEBUG  ]: [ Request ]: GET -> https://raw.githubusercontent.com/ybd-project/ytdl-core/refs/heads/dev/data/player/data.json
/stuff/node_modules/@ybd-project/ytdl-core/bundle/node.cjs:43
`.trim())}};u(U7,"MockAgent");var q7=U7;oue.exports=q7});var rF=f((Zbt,due)=>{"use strict";var uue=Symbol.for("undici.globalDispatcher.1"),{InvalidArgumentError:tVe}=Ur(),nVe=Gv();cue()===void 0&&lue(new nVe);function lue(e){if(!e||typeof e.dispatch!="function")throw new tVe("Argument agent must implement Agent");Object.defineProperty(globalThis,uue,{value:e,writable:!0,enumerable:!1,configurable:!1})}u(lue,"setGlobalDispatcher");function cue(){return globalThis[uue]}u(cue,"getGlobalDispatcher");due.exports={setGlobalDispatcher:lue,getGlobalDispatcher:cue}});var G7=f((eMt,hue)=>{"use strict";var sp,tS;hue.exports=(tS=class{constructor(t){ot(this,sp);if(typeof t!="object"||t===null)throw new TypeError("handler must be an object");Ge(this,sp,t)}onConnect(...t){var n,i;return(i=(n=U(this,sp)).onConnect)==null?void 0:i.call(n,...t)}onError(...t){var n,i;return(i=(n=U(this,sp)).onError)==null?void 0:i.call(n,...t)}onUpgrade(...t){var n,i;return(i=(n=U(this,sp)).onUpgrade)==null?void 0:i.call(n,...t)}onResponseStarted(...t){var n,i;return(i=(n=U(this,sp)).onResponseStarted)==null?void 0:i.call(n,...t)}onHeaders(...t){var n,i;return(i=(n=U(this,sp)).onHeaders)==null?void 0:i.call(n,...t)}onData(...t){var n,i;return(i=(n=U(this,sp)).onData)==null?void 0:i.call(n,...t)}onComplete(...t){var n,i;return(i=(n=U(this,sp)).onComplete)==null?void 0:i.call(n,...t)}onBodySent(...t){var n,i;return(i=(n=U(this,sp)).onBodySent)==null?void 0:i.call(n,...t)}},sp=new WeakMap,u(tS,"DecoratorHandler"),tS)});var fue=f((nMt,pue)=>{"use strict";var rVe=k4();pue.exports=e=>{let t=e==null?void 0:e.maxRedirections;return n=>u(function(o,a){let{maxRedirections:r=t,...s}=o;if(!r)return n(o,a);let l=new rVe(n,r,o,a);return n(s,l)},"redirectInterceptor")}});var mue=f((iMt,Aue)=>{"use strict";var iVe=z4();Aue.exports=e=>t=>u(function(i,o){return t(i,new iVe({...i,retryOptions:{...e,...i.retryOptions}},{handler:o,dispatch:t}))},"retryInterceptor")});var yue=f((oMt,gue)=>{"use strict";var sVe=kn(),{InvalidArgumentError:oVe,RequestAbortedError:aVe}=Ur(),uVe=G7(),eg,iF,nS,bT,rS,iS,Rf,sF,Eue,W7=class W7 extends uVe{constructor({maxSize:n},i){super(i);ot(this,sF);ot(this,eg,1024*1024);ot(this,iF,null);ot(this,nS,!1);ot(this,bT,!1);ot(this,rS,0);ot(this,iS,null);ot(this,Rf,null);if(n!=null&&(!Number.isFinite(n)||n<1))throw new oVe("maxSize must be a number greater than 0");Ge(this,eg,n??U(this,eg)),Ge(this,Rf,i)}onConnect(n){Ge(this,iF,n),U(this,Rf).onConnect(qr(this,sF,Eue).bind(this))}onHeaders(n,i,o,a){let s=sVe.parseHeaders(i)["content-length"];if(s!=null&&s>U(this,eg))throw new aVe(`Response size (${s}) larger than maxSize (${U(this,eg)})`);return U(this,bT)?!0:U(this,Rf).onHeaders(n,i,o,a)}onError(n){U(this,nS)||(n=U(this,iS)??n,U(this,Rf).onError(n))}onData(n){return Ge(this,rS,U(this,rS)+n.length),U(this,rS)>=U(this,eg)&&(Ge(this,nS,!0),U(this,bT)?U(this,Rf).onError(U(this,iS)):U(this,Rf).onComplete([])),!0}onComplete(n){if(!U(this,nS)){if(U(this,bT)){U(this,Rf).onError(this.reason);return}U(this,Rf).onComplete(n)}}};eg=new WeakMap,iF=new WeakMap,nS=new WeakMap,bT=new WeakMap,rS=new WeakMap,iS=new WeakMap,Rf=new WeakMap,sF=new WeakSet,Eue=u(function(n){Ge(this,bT,!0),Ge(this,iS,n)},"#customAbort"),u(W7,"DumpHandler");var V7=W7;function lVe({maxSize:e}={maxSize:1024*1024}){return t=>u(function(i,o){let{dumpMaxSize:a=e}=i,r=new V7({maxSize:a},o);return t(i,r)},"Intercept")}u(lVe,"createDumpInterceptor");gue.exports=lVe});var MT=f((uMt,_ue)=>{"use strict";var{kConstruct:cVe}=is(),{kEnumerableProperty:sS}=kn(),{iteratorMixin:dVe,isValidHeaderName:cB,isValidHeaderValue:Tue}=sh(),{webidl:ur}=yu(),Y7=require("node:assert"),oF=require("node:util"),ko=Symbol("headers map"),ah=Symbol("headers map sorted");function wue(e){return e===10||e===13||e===9||e===32}u(wue,"isHTTPWhiteSpaceCharCode");function Cue(e){let t=0,n=e.length;for(;n>t&&wue(e.charCodeAt(n-1));)--n;for(;n>t&&wue(e.charCodeAt(t));)++t;return t===0&&n===e.length?e:e.substring(t,n)}u(Cue,"headerValueNormalize");function vue(e,t){if(Array.isArray(t))for(let n=0;n<t.length;++n){let ...... it keeps going for a long time










TypeError: terminated
    at dP.onAborted (/stuff/node_modules/@ybd-project/ytdl-core/bundle/node.cjs:43:45438)
    at dP.emit (node:events:513:28)
    at dP.terminate (/stuff/node_modules/@ybd-project/ytdl-core/bundle/node.cjs:43:31326)
    at /stuff/node_modules/@ybd-project/ytdl-core/bundle/node.cjs:43:34405
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  [cause]: TypeError [ERR_INVALID_ARG_TYPE]: The "stream" argument must be an instance of Stream. Received an instance of ReadableStream
      at new NodeError (node:internal/errors:400:5)
      at eos (node:internal/streams/end-of-stream:66:11)
      at fetchFinale (/stuff/node_modules/@ybd-project/ytdl-core/bundle/node.cjs:43:38900)
      at mainFetch (/stuff/node_modules/@ybd-project/ytdl-core/bundle/node.cjs:43:36053)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    code: 'ERR_INVALID_ARG_TYPE'
  }
}

Node.js v18.13.0

Environment

  • Video URL:
  • @ybd-project/ytdl-core version: latest 6.0.8
  • Node.js version: 18.13.0
  • Operating system: Ubuntu
@Toidi357 Toidi357 added the bug Something isn't working label Dec 25, 2024
@ybd-project
Copy link
Owner

There seems to be no way to reliably avoid the block at this time. However, what seems to work is to generate a normal and correct PoToken and specify it in the request. (This works for yt-dlp.)
We will investigate this error, but please try the beta version.

npm i @ybd-project/ytdl-core@beta

@ybd-project ybd-project self-assigned this Dec 26, 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

2 participants