Skip to content

Commit 7c04756

Browse files
fix: fix some hypothetical racing condition
1 parent 95e7eb0 commit 7c04756

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

website/src/components/Playground.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,23 @@ watchEffect(async () => {
7777
langLoaded.value = true
7878
})
7979
80-
watchEffect(async () => {
80+
watchEffect(async (onInvalidate) => {
8181
if (!langLoaded.value || !yaml.value) {
8282
return
8383
}
84+
let invalidated = false
8485
// before async
8586
const [src, json] = [source.value, buildRules()]
87+
onInvalidate(() => invalidated = true)
8688
try {
8789
const [matches, fixed] = await doFind(src, json)
90+
if (invalidated) { return }
8891
rewrittenCode.value = fixed
8992
matchedHighlights.value = matches
9093
matchedEnvs.value = matches.map(m => m.env)
9194
ruleErrors.value = null
9295
} catch (e) {
96+
if (invalidated) { return }
9397
console.error(e)
9498
ruleErrors.value = e.toString()
9599
matchedHighlights.value = []

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy