-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ChannelMessageHandlers: Make RegisterHandler() not remove the existing handler if another one with same id is given #952
Conversation
Add a test to assert than calling `router1.pipeToRouter(router2)` fails if both `Routers` are in the same `Worker`. ### TODO The new test succeed however it **breaks** an unrelated test that runs later that should NOT be affected at all: ``` FAIL node/tests/test-PipeTransport.js ✓ router.pipeToRouter() succeeds with audio (24 ms) ✓ router.pipeToRouter() succeeds with video (21 ms) ### NEW TEST: ✓ router.pipeToRouter() fails if both Routers belong to the same Worker (32 ms) ✓ router.createPipeTransport() with enableRtx succeeds (6 ms) ✓ router.createPipeTransport() with invalid srtpParameters must fail (3 ms) ✓ router.createPipeTransport() with enableSrtp succeeds (9 ms) ✓ router.createPipeTransport() with fixed port succeeds (8 ms) ✓ transport.consume() for a pipe Producer succeeds (6 ms) ### UNRELATED FAILING TEST: ✕ producer.pause() and producer.resume() are transmitted to pipe Consumer (2 ms) ✓ producer.close() is transmitted to pipe Consumer (2 ms) ✓ router.pipeToRouter() succeeds with data (7 ms) ✓ transport.dataConsume() for a pipe DataProducer succeeds (2 ms) ✓ dataProducer.close() is transmitted to pipe DataConsumer (2 ms) ✓ router.pipeToRouter() called twice generates a single PipeTransport pair (14 ms) ✓ router.pipeToRouter() called in two Routers passing one to each other as argument generates a single a single PipeTransport pair (10 ms) ● producer.pause() and producer.resume() are transmitted to pipe Consumer Channel request handler with ID c9cba815-1128-4500-aa4f-7edbc135b889 not found [method:producer.resume] ``` It doesn't make sense that such a test fails with that error (producer not found in the worker). To simplify the error, I've added a temporal code in the new test that clearly shows the issue: ```ts test('router.pipeToRouter() fails if both Routers belong to the same Worker', async () => { const router1bis = await worker1.createRouter({ mediaCodecs }); await expect(router1.pipeToRouter( { producerId : videoProducer.id, router : router1bis })) .rejects .toThrow(Error); // TODO: Temporal code to show an unexpected error. { // This is ok. expect(videoProducer.closed).toBe(false); // However these will fail since the handler Id does not exist in the worker. // This is impossible and must be a bug. await videoProducer.resume(); await videoProducer.pause(); } router1bis.close(); }, 2000); ``` In addition, Rust test is missing but I don't want to deal with that until the issue is solved.
To be clear, it looks like this code is closing/deleting router1.pipeToRouter(
{
producerId : videoProducer.id,
router : router1bis
}); Ok, the code throws because both routers are in the same worker, but that should NOT close the given producer. @nazar-pc I cannot find anything that could cause this error. I've verified tat |
I know where the bug is. |
… handler id another one with same id is given
Adding test in Rust. |
@nazar-pc I definitely need your help in the Rust test:
|
The error comes from mediasoup/rust/src/router/transport.rs Lines 403 to 407 in 6ac1cd2
As far as Rust side is concerned, router certainly contains such producer already and it doesn't make any sense to produce it again. I don't think I fully understand what you're trying to do in this PR. |
No, it doesn't. The error comes from |
No, this is not the error. |
I see. You'll need to inspect error message then and convert it to |
|
Please help here, I've spent lot long time already trying to figure out the syntax here without success. I don't know how to inspect the error message. |
I've already searched for all error matching in Rust tests. None is similar to what it's needed here. And there is nothing about data producers that can be taken as guide. |
As you figured out, the root error is obviously So it is just a few enums nested in one another with narrowing reason of an error. I have pushed corresponding change, let me know if that is sufficient or I should still intercept it and replace with |
We have RAII in Rust, since that consumer is not stored anywhere (due to error exiting early) it'll be destroyed on drop automatically with destructor ( |
lovely! impl Drop for Inner {
fn drop(&mut self) {
debug!("drop()");
self.close(true);
}
} |
…g handler if another one with same id is given (versatica#952) Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com>
id
happens. Tis prevents the following issue discovered while adding a new unit test:It doesn't make sense that such a test fails with that error (producer not found in the worker). To simplify the error, I've added a temporal code in the new test that clearly shows the issue: