Skip to content

Commit 6ac7985

Browse files
committed
fix: fix concurrent eval BUG
1 parent 5e092b6 commit 6ac7985

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/output/srcdoc.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
color-scheme: dark;
77
}
88
body {
9-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
10-
Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
9+
font-family:
10+
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
11+
Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
1112
}
1213
</style>
1314
<!-- PREVIEW-OPTIONS-HEAD-HTML -->
1415
<script>
1516
;(() => {
1617
let scriptEls = []
18+
let lastEvalPromise = null
1719

1820
window.process = { env: {} }
1921
window.__modules__ = {}
@@ -40,7 +42,15 @@
4042
send_reply({ action: 'cmd_error', message, stack })
4143

4244
if (action === 'eval') {
45+
let evalDone
4346
try {
47+
if (lastEvalPromise) {
48+
await lastEvalPromise
49+
}
50+
lastEvalPromise = new Promise((resolve) => {
51+
evalDone = resolve
52+
})
53+
4454
if (scriptEls.length) {
4555
scriptEls.forEach((el) => {
4656
document.head.removeChild(el)
@@ -68,6 +78,9 @@
6878
send_ok()
6979
} catch (e) {
7080
send_error(e.message, e.stack)
81+
} finally {
82+
lastEvalPromise = null
83+
evalDone()
7184
}
7285
}
7386

0 commit comments

Comments
 (0)