Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Nov 29, 2024
1 parent 0aed55b commit 37ab10b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
10 changes: 8 additions & 2 deletions frontend/controller/actions/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ export const encryptedAction = (
// are written
const finished = enqueueDeferredPromise('encrypted-action')

let retainFailed = false
try {
// Writing to a contract requires being subscribed to it
// Since we're only interested in writing and we don't know whether
// we're subscribed or should be, we use an ephemeral retain here that
// is undone at the end in a finally block.
await sbp('chelonia/contract/retain', contractID, { ephemeral: true })
await sbp('chelonia/contract/retain', contractID, { ephemeral: true }).catch(e => {
retainFailed = true
throw e
})
const state = {
[contractID]: await sbp('chelonia/latestContractState', contractID)
}
Expand Down Expand Up @@ -141,7 +145,9 @@ export const encryptedAction = (
throw new GIErrorUIRuntimeError(userFacingErrStr, { cause: e })
} finally {
finished()
await sbp('chelonia/contract/release', contractID, { ephemeral: true })
if (!retainFailed) {
await sbp('chelonia/contract/release', contractID, { ephemeral: true })
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions frontend/model/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export async function createLogger (config: Object, { getItem, removeItem, setIt
}]
))
const appLogsFilter: string[] = []
// Make a copy of 'methods' to prevent reassignment by 'setAppLogsFilter'
const consoleProxy = new Proxy({ ...methods }, {
get (o, p, r) {
return Reflect.has(o, p) ? Reflect.get(o, p, r) : Reflect.get(originalConsole, p, r)
Expand Down
8 changes: 2 additions & 6 deletions shared/domains/chelonia/chelonia.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,8 @@ export default (sbp('sbp/selectors/register', {
},
// This selector is defined primarily for ingesting web push notifications,
// although it can be used as a general-purpose API to process events received
// from 'external' sources, with 'external' meaning sources not directly
// managed by Chelonia (i.e., the WebSocket connection)
// This API creates some potential asymmetry in terms of how events are ingested.
// However, it adds flexibility for application developers in terms of managing,
// e.g., web push subcriptions, which can be an involved process that in modern
// browsers requires user interaction.
// from other external sources that are not managed by Chelonia itself (i.e. sources
// other than the Chelonia-managed websocket connection and RESTful API).
'chelonia/handleEvent': async function (event: string) {
const { contractID } = GIMessage.deserializeHEAD(event)
if (self.registration) {
Expand Down

0 comments on commit 37ab10b

Please sign in to comment.