Mutex error in Input AudioStream
### Select which package(s) are affected
\@livekit/rtc-node
### Describe the bug
Input AudioStream has a very specific way to be consumed, when consumed any different, it throws a mutex error
> libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
### Reproduction
```typescript
import { Readable } from 'node:stream';
const audioStreamReader = Readable.fromWeb(new AudioStream(track, {
sampleRate: 16000,
numChannels: 1,
}));
const audioStreamReader.on('data', console.log)
```
With this code, in under 5 seconds, the worker process in agents-js crashes and throws the aforementioned log. The following code, on the other hand, keeps working until the remote stream is closed, then it throws the error
```typescript
for (const frame of new AudioStream(track, {
sampleRate: 16000,
numChannels: 1,
})) {
console.log(frame);
}
```
### Logs
```shell
None besides the one posted
```
### System Info
```shell
"@livekit/mutex": "^1.1.1",
"@livekit/noise-cancellation-node": "^0.1.9",
"@livekit/protocol": "^1.42.2",
"@livekit/rtc-node": "^0.13.20",
"@livekit/typed-emitter": "^3.0.0",
```
### LiveKit server version
LiveKit cloud
### Severity
serious, but I can work around it
### Additional Information
Working it around for now, by making sure we never close the input audio stream so all the cleanup operators can run, but its still not good having the worker process crash 100% of the time.
4 条评论