Skip to content

Commit

Permalink
Error handling (#2636)
Browse files Browse the repository at this point in the history
Closes #2624
  • Loading branch information
corrideat authored Feb 16, 2025
1 parent 2c25e3a commit defcec2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions frontend/model/contracts/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,9 @@ sbp('chelonia/defineContract', {

// Session has changed
if (actorID !== originalActorID) {
console.info('[gi.contracts/group/joinGroupChatrooms] Session changed', {
actorID, contractID, chatRoomID, originalActorID, memberID, height
})
return
}

Expand All @@ -1590,7 +1593,18 @@ sbp('chelonia/defineContract', {
state?.chatRooms?.[chatRoomID]?.members[memberID]?.status !== PROFILE_STATUS.ACTIVE ||
state?.chatRooms?.[chatRoomID]?.members[memberID]?.joinedHeight !== height
) {
sbp('okTurtles.data/set', `gi.contracts/group/chatroom-skipped-${contractID}-${chatRoomID}-${height}`, true)
console.info('[gi.contracts/group/joinGroupChatrooms] Skipping outdated action', {
actorID,
contractID,
chatRoomID,
originalActorID,
memberID,
height,
groupStatusActor: state?.profiles?.[actorID]?.status,
groupSatusMember: state?.profiles?.[memberID]?.status,
chatRoomStatus: state?.chatRooms?.[chatRoomID]?.members[memberID]?.status,
chatRoomHeight: state?.chatRooms?.[chatRoomID]?.members[memberID]?.joinedHeight
})
return
}

Expand Down Expand Up @@ -1631,7 +1645,7 @@ sbp('chelonia/defineContract', {
return
}

console.warn(`Unable to join ${memberID} to chatroom ${chatRoomID} for group ${contractID}`, e)
console.warn(`[gi.contracts/group/joinGroupChatrooms] Unable to join ${memberID} to chatroom ${chatRoomID} for group ${contractID}`, e)
}).finally(() => {
sbp('chelonia/contract/release', chatRoomID, { ephemeral: true }).catch(e => console.error('[gi.contracts/group/joinGroupChatrooms] Error during release', e))
})
Expand Down
2 changes: 1 addition & 1 deletion shared/domains/chelonia/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ export default (sbp('sbp/selectors/register', {
throw e
}
processingErrored = e?.name !== 'ChelErrorWarning'
this.config.hooks.processError?.(e, message, getMsgMeta(message, contractID, state))
this.config.hooks.processError?.(e, message, getMsgMeta(message, contractID, contractStateCopy))
// special error that prevents the head from being updated, effectively killing the contract
if (
e.name === 'ChelErrorUnrecoverable' ||
Expand Down
2 changes: 1 addition & 1 deletion shared/domains/chelonia/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ export const recreateEvent = (entry: GIMessage, state: Object, contractsState: O

export const getContractIDfromKeyId = (contractID: string, signingKeyId: ?string, state: Object): ?string => {
if (!signingKeyId) return
return signingKeyId && state._vm.authorizedKeys[signingKeyId]?.foreignKey
return signingKeyId && state._vm?.authorizedKeys?.[signingKeyId]?.foreignKey
? new URL(state._vm.authorizedKeys[signingKeyId].foreignKey).pathname
: contractID
}
Expand Down

0 comments on commit defcec2

Please sign in to comment.