replicache icon indicating copy to clipboard operation
replicache copied to clipboard

Recursion / infinite loop bug in "delete"

Open tmcw opened this issue 3 years ago • 5 comments
trafficstars

Encountering the below in prod:

RangeError: Maximum call stack size exceeded
  at ? (./node_modules/replicache/out/replicache.mjs:1:49086)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)
  at delete(./node_modules/replicache/out/replicache.mjs:1:49078)
  at ? (./node_modules/replicache/out/replicache.mjs:1:49188)
  at Array.forEach(<anonymous>)

It looks like there's some recursive code that isn't finding an end condition here.

tmcw avatar Apr 26 '22 16:04 tmcw

Thank you for the report. This looks concerning. @arv is going to look into it soon.

aboodman avatar Apr 26 '22 22:04 aboodman

@tmcw Which version is this?

arv avatar Apr 27 '22 08:04 arv

Assuming v10.0.0-beta.0 I get:

npx stacktracify out/replicache.mjs.map
RangeError: Maximum call stack size exceeded
    at  (../src/dag/lazy-store.ts:489:34)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach
    at  (../src/dag/lazy-store.ts:489:26)
    at  (../src/dag/lazy-store.ts:498:15)
    at Array.forEach

arv avatar Apr 27 '22 08:04 arv

The only way I think this can happen based on looking at the code is that a chunk is referencing itself. Something that should never happen.

@tmcw I'm going to add some asserts and attach a tarball here that you can try

arv avatar Apr 27 '22 08:04 arv

Attached is a new build with asserts as well as the sourcemap for that build.

replicache-10.0.0-beta.0.tgz.zip replicache.mjs.map.zip

arv avatar Apr 27 '22 08:04 arv

Fixed

arv avatar Oct 20 '22 20:10 arv