diff --git a/allscripts(deprecated).js b/allscripts(deprecated).js index e360c3f..341b7ec 100644 --- a/allscripts(deprecated).js +++ b/allscripts(deprecated).js @@ -69,6 +69,12 @@ register('fill', function (pat) { // Find the next onset, to use as an offset const next = onsets.find(onset => onset.gte(hap.whole.end)); + // If there is no next onset, the query window is not large enough. + // We bail out to avoid a crash. + if (next === undefined) { + continue; + } + // Ignore if the part ended before the original query, and hasn't expanded inside if (next.lte(state.span.begin)) { continue; diff --git a/prebake.strudel b/prebake.strudel index 30d8504..b1a672c 100644 --- a/prebake.strudel +++ b/prebake.strudel @@ -156,6 +156,12 @@ register('fill', function (pat) { // Find the next onset, to use as an offset const next = onsets.find(onset => onset.gte(hap.whole.end)); + // If there is no next onset, the query window is not large enough. + // We bail out to avoid a crash. + if (next === undefined) { + continue; + } + // Ignore if the part ended before the original query, and hasn't expanded inside if (next.lte(state.span.begin)) { continue;