Thread deadlock: during concurrent executions on the same sockjs socket
reproduce with this script against the cordite DAO:
const Proxy = require('braid-client').Proxy;
const emea = new Proxy({url: 'https://localhost:8081/api/'}, onOpen, onClose, onError, {strictSSL: false})
let saltedDaoName = 'testDao-'+new Date().getTime()
let notaryName = "O=Notary Service, L=Zurich, C=CH"
var daoKey
var emeaParty
var normalProposalKey
// function onOpen() {
// console.log("connected")
// emea.dao.createDao(saltedDaoName, 1, false, notaryName).then(daoState => {
// daoKey = daoState.daoKey
// console.log("emea created dao with name",saltedDaoName,"and key",daoKey)
// }).then(proposal => {
// console.log("create proposal")
// return emea.dao.createNormalProposal("change voting percentage","change the voting percentage of people needed to accept", daoKey)
// }).then(normProposalState => {
// normalProposalKey = normProposalState.proposal.proposalKey
// console.log("new proposal created with key",normalProposalKey)
// console.log("should be one supporter now", normProposalState.supporters.length)
// console.log("emea proposes to accept")
// return emea.dao.acceptProposal(normalProposalKey)
// }).then(acceptedProposal => {
// console.log("should be accepted",acceptedProposal.lifecycleState)
// console.log("and we are done :-)")
// }).catch(error => {
// console.error(error)
// })
// }
function onOpen() {
console.log("connected")
emea.dao.createDao(saltedDaoName, 1, false, notaryName).then(daoState => {
daoKey = daoState.daoKey
console.log("emea created dao with name",saltedDaoName,"and key",daoKey)
}).then(proposal => {
console.log("create proposals")
return createSomeProposals()
}).then(values => {
console.log(values)
return getAllProposalsALot()
}).then(props => {
console.log("props returned: "+props.length)
console.log("done!")
}).catch(error => {
console.error(error)
})
}
function getAllProposalsALot() {
return Promise.all([...Array(10).keys()].map(x => getAllProposals()))
}
function getAllProposals() {
return emea.dao.listProposalKeys().then(keys => {
console.log("got "+keys.length+" keys")
return Promise.all(keys.map(x => emea.dao.proposalFor(x)))
})
}
function createSomeProposals() {
return Promise.all([...Array(62).keys()].map(x => createProposal(x) ))
}
function createProposal(salt) {
return emea.dao.createNormalProposal("proposal-"+salt,"change the voting percentage of people needed to accept", daoKey)
}
function onClose() {
console.log("closed")
}
function onError(err) {
console.error(err)
}