Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cryptix opened this issue Nov 18, 2020 · 2 comments
Open

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

cryptix opened this issue Nov 18, 2020 · 2 comments
Labels

Comments

@cryptix
Copy link
Member

cryptix commented Nov 18, 2020

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.

@mixmix
Copy link
Member

mixmix commented Nov 21, 2020

Weird. The get method actually uses a flume view-level, as you can see.
After being added to a group your sbot triggers a reindex. This includes that view which feeds get. I would have thought that that view would not respond until it had indexed (might be interesting to look at sbot.progress() or sbot.status())

But it sounds like it knows what the log offset is (it quotes the offset) but then it can't access that? Weird. Need to get into it to debug it. Sigh

@stale
Copy link

stale bot commented Jun 2, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

@stale stale bot added the stale label Jun 2, 2021
@staltz staltz removed the stale label Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants