Adding Retry to Account Registration

in Witness Activities21 days ago

Given that I have seen many errors for Account Sign Up Tool I have added a simple retry and a retry in this case won't hurt much (it is not like sending assets or voting a post with different weight)

    const retry = 6;
    let count = 0;
    while (count < retry) {
      try {
        const result = await client.broadcast.sendOperations(ops, privateKey);
        console.log(result);
        await saveUser(id, password, result);
        sendEmail("Account created: " + id, JSON.stringify(result));
        break;
      } catch (error) {
        console.log(error);
        sendEmail(`Error in account creation: ${retry}, id=` + id, JSON.stringify(error));
        count++;
        await sleep(1000);
      }
    }

The errors:

Error in account creation: 7934: {name":"RPCError","jse_shortmsg":"(skip & skip_transaction_dupe_check) || trx_idx.indices().get().find(trx_id) == trx_idx.indices().get().end(): Duplicate transaction check failed trx_ix=xxxx","jse_info":{"code":10,"name":"assert_exception","message":"Assert Exception","stack":[{"context":{"level":"error","file":"database.cpp","line":3644,"method":"_apply_transaction","hostname":"","timestamp":"2025-03-24T17:02:32"},"format":"(skip & skip_transaction_dupe_check) || trx_idx.indices().get().find(trx_id) == trx_idx.indices().get().end(): Duplicate transaction check failed","data":{"trx_ix":"xxxx"}},{"context":{"level":"warn","file":"database.cpp","line":3712,"method":"_apply_transaction","hostname":"","timestamp":"2025-03-24T17:02:32"},"format":"","data":{"trx":{"ref_block_num":57249,"ref_block_prefix":534969471,"expiration":"2025-03-24T17:03:27","operations":[{"type":"create_claimed_account_operation","value":{"creator":"justyy","new_account_name":"rizwan-tariq","owner":{"weight_threshold":1,"account_auths":[],"key_auths":[["xxxx",1]]},"active":{"weight_threshold":1,"account_auths":[],"key_auths":[["xxxx",1]]},"posting":{"weight_threshold":1,"account_auths":[],"key_auths":[["xxxx",1]]},"memo_key":"xxxx","json_metadata":"","extensions":[]}}],"extensions":[],"signatures":["xxxx"]}}},{"context":{"level":"warn","file":"database.cpp","line":915,"method":"push_transaction","hostname":"","timestamp":"2025-03-24T17:02:32"},"format":"","data":{"trx":{"ref_block_num":57249,"ref_block_prefix":534969471,"expiration":"2025-03-24T17:03:27","operations":[{"type":"create_claimed_account_operation","value":{"creator":"justyy","new_account_name":"rizwan-tariq","owner":{"weight_threshold":1,"account_auths":[],"key_auths":[["xxxx",1]]},"active":{"weight_threshold":1,"account_auths":[],"key_auths":[["xxxx",1]]},"posting":{"weight_threshold":1,"account_auths":[],"key_auths":[["xxxx",1]]},"memo_key":"xxxx","json_metadata":"","extensions":[]}}],"extensions":[],"signatures":["xxxx"]}}}]},"message":"(skip & skip_transaction_dupe_check) || trx_idx.indices().get().find(trx_id) == trx_idx.indices().get().end(): Duplicate transaction check failed trx_ix=xxxx"}

Steem to the Moon🚀!