chore: Add error handling and processing status flag to knowledge queue subscription
This commit is contained in:
parent
9c8584f1c4
commit
cecb447b46
@ -3,4 +3,22 @@ import PubSub from "pubsub-js"
|
|||||||
|
|
||||||
export const KNOWLEDGE_QUEUE = Symbol("queue")
|
export const KNOWLEDGE_QUEUE = Symbol("queue")
|
||||||
|
|
||||||
PubSub.subscribe(KNOWLEDGE_QUEUE, processKnowledge)
|
let isProcessing = false
|
||||||
|
|
||||||
|
PubSub.subscribe(KNOWLEDGE_QUEUE, async (msg, id) => {
|
||||||
|
try {
|
||||||
|
isProcessing = true
|
||||||
|
await processKnowledge(msg, id)
|
||||||
|
isProcessing = false
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
isProcessing = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
window.addEventListener("beforeunload", (event) => {
|
||||||
|
if (isProcessing) {
|
||||||
|
event.preventDefault()
|
||||||
|
event.returnValue = ""
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user