weavedb / rdk

WeaveDB Rollup Development Kit
3 stars 3 forks source link

null data property in WAL contract #23

Closed drumfeet closed 6 months ago

drumfeet commented 7 months ago

I sent a PR for the test case #22

I noticed that this issue only happens if I run simultaneous write queries running on multiple CLI. Issue does not occur if I only have a single process writing to the database. When issue occurs, an error message appears on the console log Cannot set properties of null (setting 'prev'). The document is created successfully on the DB contract. However, WAL contract displays the data property as null.

Issue occurs from the rollup.js file on this code execution await this.wal.set(t, "txs", `${t.id}`) I tried to change it to the code below to capture the error.

          const _result = await Promise.allSettled([this.wal.set(t, "txs", `${t.id}`)])
          const _error = _result[0].value?.error

Then, I found that the error happened on BPT.js lib.

TypeError: Cannot set properties of null (setting 'prev')
    at BPT._split (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-contracts/weavedb-bpt/lib/BPT.js:982:17)
    at async BPT.split (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-contracts/weavedb-bpt/lib/BPT.js:1022:27)
    at async BPT.insert (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-contracts/weavedb-bpt/lib/BPT.js:932:30)
    at async put (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-contracts/weavedb-bpt/lib/index.js:527:5)
    at async set (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-contracts/weavedb-bpt/actions/write/set.js:45:27)
    at async OffChain.handle (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-contracts/weavedb-bpt/contract.js:221:40)
    at async OffChain.write (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-offchain/index.js:224:14)
    at async OffChain.writeWithoutWallet (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-offchain/node_modules/weavedb-base/index.js:1244:12)
    at async OffChain._write2 (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-offchain/node_modules/weavedb-base/index.js:389:14)
    at async OffChain._write (/Users/marss/Documents/GitHub/rdk/node/node-server/node_modules/weavedb-offchain/node_modules/weavedb-base/index.js:324:12)