# addMarkedSpan error

**URL:** <https://discuss.codemirror.net/t/addmarkedspan-error/4256>\
**Category:** Uncategorized\
**Created:** [April 11, 2022, 8:26am UTC](https://discuss.codemirror.net/t/addmarkedspan-error/4256 "2022-04-11T08:26:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brojgar](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/b/779978/32.png) [@brojgar](https://discuss.codemirror.net/u/brojgar)\
**Post date:** [April 11, 2022, 8:26am UTC](https://discuss.codemirror.net/t/addmarkedspan-error/4256/1 "2022-04-11T08:26:50Z")

</div>

Hi, I upgraded cm library from 5.58.1 to 5.65.2 in my nw.js application and now everything connected to setting text markers throws: “Uncaught TypeError: Invalid value used in weak set” in line 1327:

```auto
  function addMarkedSpan(line, span, op) {
    var inThisOp = op && window.WeakSet && (op.markedSpans || (op.markedSpans = new WeakSet));
    if (inThisOp && inThisOp.has(line.markedSpans)) { // breaks here
      line.markedSpans.push(span);
    } else {
      line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
      if (inThisOp) { inThisOp.add(line.markedSpans); }
    }
    span.marker.attachLine(line);
  }

```

Was this reported before?

Thanks for any insight.

i.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [April 11, 2022, 8:50am UTC](https://discuss.codemirror.net/t/addmarkedspan-error/4256/2 "2022-04-11T08:50:53Z")

</div>

Thanks for the report. This patch should help with this.

> <https://github.com/codemirror/CodeMirror/commit/b4112c6bb26652fb886478fa68127ece9a59f254>
>
> See https://discuss.codemirror.net/t/addmarkedspan-error/4256

---

<div class="post-metadata">

**Author:** ![brojgar](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/b/779978/32.png) [@brojgar](https://discuss.codemirror.net/u/brojgar)\
**Post date:** [April 12, 2022, 3:14pm UTC](https://discuss.codemirror.net/t/addmarkedspan-error/4256/3 "2022-04-12T15:14:29Z")

</div>

Thanks, that solves all the problems for me.  
Regards,  
iztok
