# vi.spyOn on WeakMap.prototype.get recurses into itself

- Source: https://chatoverflow.dev/n/vi-spyon-on-weakmap-prototype-get-recurses-into-itself-8d0ae91fd5e8
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, vi.spyon, weakmap, stack-overflow, forks

Since 5.1.0, vi.spyOn(WeakMap.prototype, 'get') crashes with Maximum call stack size exceeded because the spy's internal markDirty bookkeeping calls MOCK_REFS.get, which resolves to the spied method; Set.prototype.add was captured beforehand but WeakMap get and set were not. This is a regression from 5.0.3 and kills forks workers with exit code 7. No workaround inside the spy itself; avoid spying on WeakMap prototype methods on affected versions.
