dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.8k stars 374 forks source link

Missing command registration causes deadlock when command is deserialized #3474

Open shyamnamboodiripad opened 4 months ago

shyamnamboodiripad commented 4 months ago

When we forget to register commands, currently the kernel.SendAsync call from a remote process into the process where the command is deserialized deadlocks.

We fixed one such deadlock in #3471. But the code shouldn't deadlock when a command is not registered for serialization - instead it should just throw an exception.

To reproduce the problem, revert the one line fix in #3471 add a test like the one added in this commit.

Finally, there are also some undesirable aspects of the command registration being static (since it pollutes process state for unit tests some of which is captured in #2884). If we can make this non-static (and perhaps register commands during an early initialization step such as kernel host wire up) that could solve the headaches and make it easier to add tests that catch missing command registration / serialization issues.