Max Depth

Minimum Version: 2.5.0 / 3.5.0

Prevent infinite loops: Max Depth

As part of the 2.5.x / 3.5.x release, we have now the capability to limit the event execution pipeline up to a certain depth.

This is specially useful if you have plugins calling each other, and the likelyhood of exceeding that threshold is possible.

Without this capability , unit test execution might be stuck in an infinite loop until the test runner times out: and that’s simply not cool.

So, the pipeline simulation now has a default max depth of 8 (this matches the Dataverse default).

The sample below reproduces this scenario by executing a plugin that calls itself, until the threshold is exceeded, returnning an OrganizationServiceFault that would match what the platform would return in that scenario.

Infinite loop exception

Increasing the Depth

If for whatever you need to increase that limit, for example, if you have an on-premise implementation where you already modified that limit, you can also change the default MaxDepth in FakeXrmEasy.

As part of your middleware configuration, simply pass a new property in PipelineOptions called MaxDepth, this will allow you to override that threshold.

    .AddPipelineSimulation(new PipelineOptions()
                {
                    MaxDepth = 10
                })

That’s it!

Hope this information was useful, and enjoy a happy-hassle-free coding experience!