Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling #2636

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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