amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.14k stars 1.17k forks source link

calling `put` with the same option object caused an unexpected behavior #1142

Closed oOBoomberOo closed 3 years ago

oOBoomberOo commented 3 years ago

gun: 0.2020.1235 environment: browser, chrome


I found this behavior while testing the certificate feature of SEA where the 2nd call of put seemingly never get call. I suspect that the put method mutated the input option to compute something and did not clean that up afterward.

Reproducible Example:

const alice = await SEA.pair();

const cert = await SEA.certify('*', 'foo', alice);
const options = {opt: { cert }} // <-- The important part

const foo = gun.get(`~${alice.pub}`).get('foo');

gun.user().auth(alice, () => {
  // callback1 will be called
  foo.put('test #1', callback1, options);
  // however, callback2 will never be called.
  foo.put('test #2', callback2, options);
});

you can inline options and it will behaved as expected

// Both will be called
foo.put('test #1', callback1, {opt: { cert }});
foo.put('test #2', callback2, {opt: { cert }});
mimiza commented 3 years ago

Reported here: #1093

oOBoomberOo commented 3 years ago

great! I will close this for that one then.