Skip to content

Commit

Permalink
Error handling
Browse files Browse the repository at this point in the history
Closes #2624
  • Loading branch information
corrideat committed Feb 16, 2025
1 parent 26fa3f1 commit 8a1db50
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions frontend/model/contracts/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,7 @@ 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 +1591,7 @@ 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 +1632,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 8a1db50

Please sign in to comment.