okTurtles / group-income

A decentralized and private (end-to-end encrypted) financial safety net for you and your friends.
https://groupincome.org
GNU Affero General Public License v3.0
329 stars 43 forks source link

Testing website is broken (users not joining properly) #2064

Open taoeffect opened 3 months ago

taoeffect commented 3 months ago

Problem

User appears to join group but their name isn't shown in the chat and their user doesn't appear in the user list.

Screenshot 2024-06-13 at 11 15 44 AM

Screenshot 2024-06-13 at 11 15 49 AM

But - if page is refreshed, then it shows:

Screenshot 2024-06-13 at 11 20 57 AM

And everything is fine.

Solution

Find and fix the problem.

Database is attached.

groupincome.testing-2024-06-13.db.zip

taoeffect commented 3 months ago

Note that one of the errors I'm seeing on the backend is:

[11:19:57.845] ERROR (77): GET /eventsAfter/undefined/0 contractID undefined doesn't exist!                                                                                                                                                                                                                                  
    err: {                                                                                                                                                                                                                                                                                                                   
      "type": "Error",                                                                                                                                                                                                                                                                                                       
      "message": "contractID undefined doesn't exist!",                                                                                                                                                                                                                                                                      
      "stack":                                                                                                                                                                                                                                                                                                               
          Error: contractID undefined doesn't exist!                                                                                                                                                                                                                                                                         
              at Object.backend/db/streamEntriesAfter (/home/unpriv/gi/backend/database.js:47:18)                                                                                                                                                                                                                            
              at /home/unpriv/gi/backend/routes.js:128:20                                                                                                                                                                                                                                                                    
              at exports.Manager.execute (/home/unpriv/gi/node_modules/@hapi/hapi/lib/toolkit.js:60:28)                                                                                                                                                                                                                      
              at Object.internals.handler (/home/unpriv/gi/node_modules/@hapi/hapi/lib/handler.js:46:20)                                                                                                                                                                                                                     
              at exports.execute (/home/unpriv/gi/node_modules/@hapi/hapi/lib/handler.js:31:20)                                                                                                                                                                                                                              
              at Request._lifecycle (/home/unpriv/gi/node_modules/@hapi/hapi/lib/request.js:372:32)                                                                                                                                                                                                                          
              at Request._execute (/home/unpriv/gi/node_modules/@hapi/hapi/lib/request.js:280:9)                                                                                                                                                                                                                             
      "data": null,                                                                                                                                                                                                                                                                                                          
      "isBoom": true,                                                                                                                                                                                                                                                                                                        
      "isServer": false,                                                                                                                                                                                                                                                                                                     
      "output": {                                                                                                                                                                                                                                                                                                            
        "statusCode": 404,                                                                                                                                                                                                                                                                                                   
        "payload": {                                                                                                                                                                                                                                                                                                         
          "statusCode": 404,                                                                                                                                                                                                                                                                                                 
          "error": "Not Found",                                                
          "message": "contractID undefined doesn't exist!"                     
        },
        "headers": {}
      }
    }
[11:19:57.846] ERROR (77): Debug: handler, error 
    Error: contractID undefined doesn't exist!
    at Object.backend/db/streamEntriesAfter (/home/unpriv/gi/backend/database.js:47:18)
    at /home/unpriv/gi/backend/routes.js:128:20
    at exports.Manager.execute (/home/unpriv/gi/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
    at Object.internals.handler (/home/unpriv/gi/node_modules/@hapi/hapi/lib/handler.js:46:20)
    at exports.execute (/home/unpriv/gi/node_modules/@hapi/hapi/lib/handler.js:31:20)
    at Request._lifecycle (/home/unpriv/gi/node_modules/@hapi/hapi/lib/request.js:372:32)
    at Request._execute (/home/unpriv/gi/node_modules/@hapi/hapi/lib/request.js:280:9)
[11:20:14.230] ERROR (77): GET /eventsAfter/undefined/0 contractID undefined doesn't exist!
    err: {
      "type": "Error",
      "message": "contractID undefined doesn't exist!",
      "stack":
          Error: contractID undefined doesn't exist!
              at Object.backend/db/streamEntriesAfter (/home/unpriv/gi/backend/database.js:47:18)
              at /home/unpriv/gi/backend/routes.js:128:20
              at exports.Manager.execute (/home/unpriv/gi/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
              at Object.internals.handler (/home/unpriv/gi/node_modules/@hapi/hapi/lib/handler.js:46:20)
              at exports.execute (/home/unpriv/gi/node_modules/@hapi/hapi/lib/handler.js:31:20)
              at Request._lifecycle (/home/unpriv/gi/node_modules/@hapi/hapi/lib/request.js:372:32)
              at Request._execute (/home/unpriv/gi/node_modules/@hapi/hapi/lib/request.js:280:9)
      "data": null,             
      "isBoom": true,
      "isServer": false,
      "output": {
        "statusCode": 404,
        "payload": {
          "statusCode": 404,
          "error": "Not Found",
          "message": "contractID undefined doesn't exist!"
        },
        "headers": {}
      }                         
    }
corrideat commented 3 months ago

The undefined thing, although probably harmless by itself, shouldn't be happening and I believe I've found most instances where it happens (finding all instances requires a pretty deep look and analysis of the codebase). It is / was also probably related to this error, in the sense that it'd happen when attempting to display a user profile with an undefined contract ID.

Now, regarding this error, I'm still investigating. It's quite weird, because the situations that'd make it happen require several things going wrong somewhere.

If a member's contract is removed, it'd result in the undefined issue above. You also wouldn't see them as a member in the chatroom if you clicked on the 'X members' text. These things I've fixed.

However, what's strange here is that you have both text saying 1 members (it should say 2, obviously) and the z9... Joined general text. The Joined general message is created in gi.contracts/chatroom/join/process, right after updating .members. Since the member count seems to come from .members directly, the count should be 2, not 1. Well, this unless the member later was removed (talking at the state level, not specifically saying that Alex left the group or chatroom, which I know didn't happen) without triggering another notification nor an error.

I don't suppose you still have the state, do you? Whenever such weird things happen, especially those that are hard to reproduce, a full copy of the state (state/vuex/state), logs and database is useful, in that order.