Marked ranges with null from and to

I have code like the following:

    addComment(from, to, text, id, mode) {
        if (!comments[id]) {
            if (!from.cmp(to)) to = from.move(1)
            let range = pm.markRange(from, to, { className: "mode-"+mode})
            comments[id] = new Comment(id, text, range, mode)

The range returns null positions for from and to. If I put logging in pm.markRange, the first range also has null positions (which is resumably the range above) but there is a later invocation of pm.markRange with the ranges filled in. How do I retrieve the correct range?

In further testing, this may be a timing issue. If I wait, some of the ranges get updated but some never do.

Right after you create your marker, it will have non-null positions. They are only set to null when the marker (or the content it covers) is deleted.