Skip to content

v20 / private-groups: races around sbot.get({private: true, id}) #317

@cryptix

Description

@cryptix

in reverse to #316 and in similar spirit, I found this testing what happens when go-ssb creates the group and invites a JS side.

Somehow I'm getting this error around 20% of the times, even with a huge setTimeout after the sync is done and the go-bot disconnected. The full code is here but let me quote the relevant JS sbot code, too:

	let inviteMsg = %q // passed from the go-side
	sbot.replicate.request(testBob, true)
	run() // connect to the go side (which already published it's group messages)

	// check if we got the stuff once bob disconnects
	sbot.on('rpc:connect', rpc => rpc.on('closed', () => {
		setTimeout(() => {
			sbot.get({private: true, id: inviteMsg}, (err, msg) => {
				t.error(err, "got hello group msg")
				t.true(msg.meta.private, 'did decrypt')
				t.equal("what's up alice?", msg.content.text, 'has the right welcome text')
				// console.warn(JSON.stringify(msg, null, 2))
				exit()
			})
		}, 5000) // was getting the error below
	}))
not ok 3 got hello group msg
  ---
    operator: error
    at: <anonymous> (/home/cryptix/go-repos/ssb/tests/node_modules/ssb-db/create.js:70:25)
    stack: |-
      TypeError: flumeview-level.get: index for: %x+5CduWrrxQFvNoViY7v8r2In/9v9aIOR1Q97/7pcNM=.sha256pointed at:18247but log error
          at /home/cryptix/go-repos/ssb/tests/node_modules/flumeview-level/index.js:170:17
          at /home/cryptix/go-repos/ssb/tests/node_modules/ssb-db/minimal.js:54:7
          at /home/cryptix/go-repos/ssb/tests/node_modules/flumelog-offset/frame/recoverable.js:48:11
        TypeError: Cannot read property 'private' of undefined
          at eval (eval at <anonymous> (/home/cryptix/go-repos/ssb/tests/sbot.js:98:3), <anonymous>:11:20)
          at /home/cryptix/go-repos/ssb/tests/node_modules/ssb-db/create.js:85:14
          at /home/cryptix/go-repos/ssb/tests/node_modules/flumeview-level/index.js:180:15
          at /home/cryptix/go-repos/ssb/tests/node_modules/ssb-db/minimal.js:52:7
          at /home/cryptix/go-repos/ssb/tests/node_modules/ssb-db/minimal.js:41:35
          at AsyncJobQueue.runAll (/home/cryptix/go-repos/ssb/tests/node_modules/ssb-db/util.js:197:32)
          at Array.<anonymous> (/home/cryptix/go-repos/ssb/tests/node_modules/ssb-db/minimal.js:41:22)
          at chainMaps (/home/cryptix/go-repos/ssb/tests/node_modules/ssb-db/minimal.js:61:14)
          at /home/cryptix/go-repos/ssb/tests/node_modules/flumedb/index.js:119:14
          at /home/cryptix/go-repos/ssb/tests/node_modules/flumelog-offset/inject.js:93:9
  ...

I find this concerning because sbot.get should (IMHO) either return the still encrypted or readable message. It feels like poking in there while the decryption updating is happening is dragon territory.

Here are the reproduction steps, similar to the other issue. If you checked that out already, just a pass -run GroupsGoCreate instead for this test case:

git clone https://github.com/cryptoscope/ssb go-ssb
cd go-ssb/tests
git checkout private-groups-4
npm ci
go test -run GroupsGoCreate -count 30 -failfast

Increasing the setTimeout befor the sbot.get from 5 to 10 seconds seems to help a bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions