After updating from 0.9.99997 to 0.9.999993 (or that's when I first noticed, I can't get the soul anymore from the chain of .set.
Example code to reproduce the issue:
const Gun = require('gun');
const gun = Gun();
let code = 1000;
let commit = new Date().getTime() + 60000;
let soul = false;
let codeRef = gun.get('codes').set({ code, commit }, function() {
console.log('CALLBACK CALLED:', arguments);
console.log('SOUL:', soul = Gun.node.soul(codeRef));
});
// Go async
(async ()=>{
while(!soul) await new Promise(r=>setTimeout(r,100));
console.log(soul);
})();
Expected behavior:
Gun.node.soul returning the soul, instead of undefined.
The work-around I'm currently using, as suggested by @bugs181, is to use the ack in the .set callback to fetch the soul.
const Gun = require('gun');
const gun = Gun();
let code = 1000;
let commit = new Date().getTime() + 60000;
let codeRef = gun.get('codes').set({ code, commit });
console.log(codeRef._.soul);
For clarification, codeRef._.soul was an improvement/discovery by @finwo. Originally, we were just fetching the node from the callback and using it's soul in there. The improvement here is that you don't need a nested callback. Nice find!
As Mark mentioned in the chat, Gun.node.soul never worked on chain references.
I may have not noticed that, because I'm always using Gun.node.soul(ref) || (ref && ref['#']) || ref; from a wrapper to fetch a reference to whatever that data is & only now I'm trying to directly use gun's version.
Would you consider this issue as closed since it was never a part of the API?
Yes, I would consider it done.
I may send a PR in the future to implement it.