Closed ibc closed 3 months ago
I've taken a look to all tests in which we call producer.pause()
and AFAIS everything is ok, but the issue still exists.
Here another unrelated PR in which same test is failing:
https://github.com/versatica/mediasoup/actions/runs/8788437337/job/24115870840?pr=1380#step:7:60
https://github.com/versatica/mediasoup/blob/0cb131cd3d1dc95cc09ee6e82dc556d8f4822117/node/src/Router.ts#L1265
The error seems to occur if the test ends without waiting for this pause
promise to fully complete. This is more likely to occur in slow running environments. It seems possible to work around this by delaying the completion of the test a bit, but I think the correct approach is to wait for this completion if possible.
The error seems to occur if the test ends without waiting for this
pause
promise to fully complete. This is more likely to occur in slow running environments. It seems possible to work around this by delaying the completion of the test a bit, but I think the correct approach is to wait for this completion if possible.
Very good point! And the issue is reproducible locally doing this change:
diff --git a/node/src/Router.ts b/node/src/Router.ts
index c60476805..33dfc343a 100644
--- a/node/src/Router.ts
+++ b/node/src/Router.ts
@@ -1262,9 +1262,15 @@ export class Router<
// Pipe events from the pipe Consumer to the pipe Producer.
pipeConsumer!.observer.on('close', () => pipeProducer!.close());
- pipeConsumer!.observer.on('pause', () => pipeProducer!.pause());
- pipeConsumer!.observer.on('resume', () => pipeProducer!.resume());
-
+ console.log('UNCOMMENT AND REMOVE');
+ // pipeConsumer!.observer.on('pause', () => pipeProducer!.pause());
+ pipeConsumer!.observer.on('pause', () =>
+ setTimeout(() => pipeProducer!.pause(), 1000)
+ );
+ // pipeConsumer!.observer.on('resume', () => pipeProducer!.resume());
+ pipeConsumer!.observer.on('resume', () =>
+ setTimeout(() => pipeProducer!.resume(), 1000)
+ );
// Pipe events from the pipe Producer to the pipe Consumer.
pipeProducer.observer.on('close', () => pipeConsumer!.close());
and then:
npx jest --testPathPattern node/src/test/test-PipeTransport.ts
Fixed here: https://github.com/versatica/mediasoup/commit/dedfb24a6a5c5c25ee91744b10bc426e3dbdf5cc
Thanks @satoren!
As shown in CI: https://github.com/versatica/mediasoup/actions/runs/8619867847/job/23625492760?pr=1373
Note that we already had these kind of errors in the past and, in same cases, they were produced by other tests that were still running code once completed.