Skip to content

Commit

Permalink
fix: async tags api runtime placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jan 7, 2025
1 parent c59f4d6 commit 5cc3648
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 141 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-jobs-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/runtime-tags": patch
---

Fix async runtime placeholder duplication and race condition.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Render "End"
```html
aERROR!efg
aERROR!def
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


# Write
<!--M_!a-->efg<style M_>t{display:none}</style><t c M_=a>ERROR!</t><script>WALKER_RUNTIME("M")("_");REORDER_RUNTIME(M._);M._.w()</script>
<!--M_!a-->def<style M_>t{display:none}</style><t M_=a>ERROR!</t><script>WALKER_RUNTIME("M")("_");REORDER_RUNTIME(M._);M._.w()</script>


# Render "End"
Expand All @@ -17,7 +17,7 @@
</style>
</head>
<body>
aERROR!efg
aERROR!def
<script>
WALKER_RUNTIME("M")("_");REORDER_RUNTIME(M._);M._.w()
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const renderer = () => {
() => {
write("b");
fork(rejectAfter(new Error("ERROR!"), 2), write);
write("d");
write("c");
},
(err) => {
write((err as Error).message);
},
);
write("e");
fork(resolveAfter("f", 1), write);
write("g");
write("d");
fork(resolveAfter("e", 1), write);
write("f");
};

export default createTemplate("", renderer);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const firstComponent = () => {
write("d");
},
() => {
write("e...");
write("_A_");
},
);
write("e");
Expand All @@ -30,18 +30,18 @@ const firstComponent = () => {
};

const secondComponent = () => {
write("v");
write("1");
tryPlaceholder(
() => {
write("w");
fork(resolveAfter("x", 2), write);
write("y");
write("2");
fork(resolveAfter("3", 2), write);
write("4");
},
() => {
write("z...");
write("_B_");
},
);
write("z");
write("5");
};

export default createTemplate("", renderer);
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Render "End"
```html
abdfgh
<t
c=""
m_="b"
>
cd
</t>
abcdefg
```
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Write
a<!--M_!^a-->e...<!--M_!a-->f<style M_>t{display:none}</style><t M_=a>b<!--M_#b-->d</t><script>WALKER_RUNTIME("M")("_");REORDER_RUNTIME(M._);M._.w()</script>
a<!--M_!^a-->_A_<!--M_!a-->e<style M_>t{display:none}</style><t M_=a>b<!--M_#b-->d</t><script>WALKER_RUNTIME("M")("_");REORDER_RUNTIME(M._);M._.w()</script>


# Write
gh
fg


# Write
<t c M_=b>cd</t><script>M._.w()</script>
<t M_=b>c</t><script>M._.w()</script>


# Render "End"
Expand All @@ -21,19 +21,11 @@
</style>
</head>
<body>
ab
<!--M_#b-->
df
abcde
<script>
WALKER_RUNTIME("M")("_");REORDER_RUNTIME(M._);M._.w()
</script>
gh
<t
c=""
m_="b"
>
cd
</t>
fg
<script>
M._.w()
</script>
Expand All @@ -55,23 +47,27 @@ inserted #document/html0/head0/style0
inserted #document/html0/head0/style0/#text0
inserted t
inserted #document/html0/body1/#text1
inserted #document/html0/body1/#comment2
inserted #comment
inserted #document/html0/body1/#text3
inserted #document/html0/body1/script5
inserted #document/html0/body1/script5/#text0
removed #document/html0/head0/style0 after #document/html0/body1/#text4
inserted #document/html0/head0/style0
inserted #document/html0/body1/#text6
inserted #document/html0/body1/t7
inserted #document/html0/body1/t7/#text0
inserted #document/html0/body1/script8
inserted #document/html0/body1/script8/#text0
inserted t
inserted #document/html0/body1/#text2
inserted #document/html0/body1/script7
inserted #document/html0/body1/script7/#text0
removed #document/html0/body1/#text2 in t
removed #comment after #document/html0/body1/#text1
inserted #document/html0/body1/#text2
removed t after #document/html0/body1/#text6
removed #text after #comment
removed #comment after #comment
removed #document/html0/body1/#text1 before #document/html0/body1/#comment2
removed #document/html0/body1/#comment2 before #document/html0/body1/#text3
removed #document/html0/body1/#text1 before #document/html0/body1/#text2
removed #document/html0/body1/#text2 before #document/html0/body1/#text3
removed #document/html0/body1/#text3 in t
removed #comment after #document/html0/body1/#text0
inserted #document/html0/body1/#text1, #document/html0/body1/#comment2, #document/html0/body1/#text3
inserted #document/html0/body1/#text1, #document/html0/body1/#text2, #document/html0/body1/#text3
removed t after #document/html0/body1/#text4
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const renderer = () => {
write("d");
},
() => {
write("e...");
write("_A_");
},
);
write("f");
fork(resolveAfter("g", 1), write);
write("h");
write("e");
fork(resolveAfter("f", 1), write);
write("g");
};

export default createTemplate("", renderer);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Render "End"
```html
abdef
abcde
```
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Write
abd
abc


# Write
ef
de


# Render "End"
```html
<html>
<head />
<body>
abdef
abcde
</body>
</html>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const renderer = () => {
write("b");
},
() => {
write("c...");
write("_A_");
},
);
write("d");
fork(resolveAfter("e", 1), write);
write("f");
write("c");
fork(resolveAfter("d", 1), write);
write("e");
};

export default createTemplate("", renderer);
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Render "End"
```html
abdeg
<t
c=""
m_="d"
>
fg
</t>
abcdefghij
```
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Write
a<!--M_!^a-->i...<!--M_!a-->j<style M_>t{display:none}</style><t M_=a>b<!--M_#b-->d<!--M_!^c-->h...<!--M_!c--></t><t M_=c>e<!--M_#d-->g</t><script>WALKER_RUNTIME("M")("_");REORDER_RUNTIME(M._);M._.w()</script>
a<!--M_!^a-->_B_<!--M_!a-->h<style M_>t{display:none}</style><t M_=a>b<!--M_#b-->d<!--M_!^c-->_A_<!--M_!c--></t><t M_=c>e<!--M_#d-->g</t><script>WALKER_RUNTIME("M")("_");REORDER_RUNTIME(M._);M._.w()</script>


# Write
kl
ij


# Write
<t c M_=b>cd<!--M_!^c-->h...<!--M_!c--></t><script>M._.w()</script>
<t M_=b>c</t><script>M._.w()</script>


# Write
<t c M_=d>fg</t><script>M._.w()</script>
<t M_=d>f</t><script>M._.w()</script>


# Render "End"
Expand All @@ -25,20 +25,14 @@
</style>
</head>
<body>
ab
<!--M_#b-->
de
<!--M_#d-->
g
abcdefgh
<script>
WALKER_RUNTIME("M")("_");REORDER_RUNTIME(M._);M._.w()
</script>
ij
<script>
M._.w()
</script>
<t
c=""
m_="d"
>
fg
</t>
<script>
M._.w()
</script>
Expand All @@ -55,54 +49,58 @@ inserted #document/html0/body1/#text0
inserted #comment
inserted #text
inserted #comment
inserted #text
inserted #document/html0/body1/#text7
inserted #document/html0/head0/style0
inserted #document/html0/head0/style0/#text0
inserted t
inserted #document/html0/body1/#text1
inserted #document/html0/body1/#comment2
inserted #comment
inserted #document/html0/body1/#text3
inserted #comment
inserted #text
inserted #comment
inserted t
inserted #document/html0/body1/#text4
inserted #document/html0/body1/#comment5
inserted #comment
inserted #document/html0/body1/#text6
inserted script
inserted script/#text0
removed #document/html0/head0/style0 after #text
inserted #document/html0/body1/script8
inserted #document/html0/body1/script8/#text0
removed #document/html0/head0/style0 after #document/html0/body1/#text7
inserted #document/html0/head0/style0
inserted #text
inserted #document/html0/body1/#text9
inserted t
inserted t/#text0
inserted t/#comment1
inserted t/#text2
inserted t/#comment3
inserted #document/html0/body1/script7
inserted #document/html0/body1/script7/#text0
inserted #document/html0/body1/#text2
inserted #document/html0/body1/script10
inserted #document/html0/body1/script10/#text0
removed #document/html0/body1/#text2 in t
removed #comment after #document/html0/body1/#text1
inserted #document/html0/body1/#text2
removed t after #document/html0/body1/#text9
removed #text after #comment
removed #comment after #comment
removed #document/html0/body1/#text1 before #document/html0/body1/#comment2
removed #document/html0/body1/#comment2 before #document/html0/body1/#text3
removed #document/html0/body1/#text1 before #document/html0/body1/#text2
removed #document/html0/body1/#text2 before #document/html0/body1/#text3
removed #document/html0/body1/#text3 before #comment
removed #comment before #text
removed #text before #comment
removed #comment in t
removed #comment after #document/html0/body1/#text0
inserted #document/html0/body1/#text1, #document/html0/body1/#comment2, #document/html0/body1/#text3, #comment, #text, #comment
removed t after #text
inserted #document/html0/body1/t8
inserted #document/html0/body1/t8/#text0
inserted #document/html0/body1/script9
inserted #document/html0/body1/script9/#text0
inserted #document/html0/body1/#text1, #document/html0/body1/#text2, #document/html0/body1/#text3, #comment, #text, #comment
removed t after #document/html0/body1/#text7
inserted t
inserted #document/html0/body1/#text5
inserted #document/html0/body1/script11
inserted #document/html0/body1/script11/#text0
removed #document/html0/body1/#text5 in t
removed #comment after #document/html0/body1/#text4
inserted #document/html0/body1/#text5
removed t after #document/html0/body1/script10
removed #text after #comment
removed #comment after #comment
removed #text after #comment
removed t after #comment
removed script after #comment
removed #text after #comment
removed t after #comment
removed #document/html0/body1/#text4 before #document/html0/body1/#text5
removed #document/html0/body1/#text5 before #document/html0/body1/#text6
removed #document/html0/body1/#text6 in t
removed #comment after #document/html0/body1/#text3
inserted #document/html0/body1/#text4, #document/html0/body1/#comment5, #document/html0/body1/#text6
inserted #document/html0/body1/#text4, #document/html0/body1/#text5, #document/html0/body1/#text6
removed t after #document/html0/body1/#text7
```
Loading

0 comments on commit 5cc3648

Please sign in to comment.