Assume we have the following two measure somewhere in a musicxml sheet:

There is a decrescendo sign that belongs to both measures.
Now, if I try to render only measure 2, then I get an error since that measure is missing the property 'isPartOfMultiStaffInstrument'. If I only try to render measure 3, everything is fine;

Obviously, to render measure 2, OSMD expects that all visual elements that require more future measures are also available. If it's not the case, OSMD is not stable enough to simply not render such elements.
I recommend the following behavior:
Whenever a single measure/multiple measures are rendered which contain elements _that go beyond the selected measures_ using drawFromMeasureNumber and drawToMeasureNumber, then all such visual elements are omitted, even though relevant information may be missing. This is better then not displaying any music sheet information at all.
The viewer is responsible for interpreting the information correctly and OSMD should be stable enough to deal with such situations,
Here is a minimal working example to reproduce the issue. The music sheet used above is included as well.
It seems that the issue does not persist for partial slurs as you can verify in this minimal working example.
This is fixed now (only for develop branch, until next release).
sample:
crescendo_range_error_sample.musicxml.zip
osmd.setOptions({drawFromMeasureNumber: 3, drawUpToMeasureNumber: 3})
You're right that visual elements should ideally be omitted instead of crashing because they couldn't be rendered. Unfortunately, try/catch can cost quite a bit of performance, so i'd rather avoid it. I did have to add it in this case though, because the rendering method for dynamics isn't suited for render range cases like this yet.
OSMD wasn't originally made for selecting a range of measures to draw, and this option is relatively new, so this is a bug that slipped through. I tested it a lot though and i hope such a problem shouldn't occur so easily anymore.
thanks @dnlfrst for the sample and reproduction steps. Xml sample and options to set would have been enough, but i appreciate the working example (=
The fix is now released with the new OSMD version 0.7.3.
Most helpful comment
The fix is now released with the new OSMD version 0.7.3.