I get exception has been thrown by the change feed processor delegate. The reader's MaxDepth of 64 has been exceeded.
I am only looking for workaround to increase maxdepth 128 We cannot change payload structure.
Tried many things but nothing is helpful
Example document to reproduce
{"id": "foo", "a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":{"a":1}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
This was a fairly recent change in response to this issue (which states that nesting levels of ~20K can cause StackOverFlow exceptions and high levels in general use more CPU/RAM). Unfortunately no new property was added to
CosmosSerializationOptionsto easily override the 64 selection if inadequate.As a POC I was able to get around this issue by changing my
Startup.csto the belowAnd temporarily "borrowing" the code from the
CosmosJsonDotNetSerializerclass in the SDK and changingMaxDepth = 64to128.That code is "Copyright (c) Microsoft Corporation." however so I wouldn't want to just go ahead and use it in a project - but at least it shows one way of implementing the expected interface with
Newtonsoft.Jsonthat you can have a look at and learn from.I'm not sure if you need to actually supply any implementation of
ToStreamat all for the use case of deserializing change feed documents or can just use.I didn't see it being called but my testing was extremely superficial.
TBH it is probably quite unwelcome news that you even have to think about this when all you want to do is get your documents available in the function so maybe you should create a feedback request asking for this to be exposed via
CosmosSerializationOptions.