prism-media icon indicating copy to clipboard operation
prism-media copied to clipboard

The value of "sourceEnd" is out of range error in 2.0.0-alpha.0

Open tony-ist opened this issue 2 years ago • 1 comments

Issue:

RangeError [ERR_OUT_OF_RANGE]: The value of "sourceEnd" is out of range. It must be >= 0 && <= 3. Received 8 
  at validateOffset (node:buffer:113:3)
  at Buffer.compare (node:buffer:895:5) 
  at Decoder._transform (/Users/tony/Projects/aoede-bot/node_modules/prism-media/src/opus/Decoder.ts:23:13)
  ...

I get the aforementioned error when working with opus.Decoder from prism-media version 2.0.0-alpha.0. It originates there at chunk.compare call. I guess it is because of a small chunk with a length of 3. Any ideas how to fix?

Steps to reproduce:

const listenStream = connection.receiver.subscribe(userId, {
  end: {
    behavior: EndBehaviorType.AfterSilence,
    duration: 1000,
  },
})

const opusDecoder = new prism.opus.Decoder({
  frameSize: 960,
  channels: 1,
  rate: 48000,
})

inputStream.pipe(opusDecoder)

Further details:

  • Operating System: MacOS 11.5.2
  • Node.js version: 16.14.2
  • Commit I'm using: 2.0.0-alpha.0

tony-ist avatar Jun 27 '22 23:06 tony-ist

I'm having exactly the same issue with the same code

dcapape avatar Sep 18 '22 15:09 dcapape