Skip to content

Commit df7f03c

Browse files
committed
fix: improve async tests stability and performance
1 parent 4cc4586 commit df7f03c

File tree

92 files changed

+221
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+221
-292
lines changed

.sizes.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
{
88
"name": "*",
99
"total": {
10-
"min": 20305,
11-
"brotli": 7778
10+
"min": 20366,
11+
"brotli": 7802
1212
}
1313
},
1414
{

.sizes/dom.js

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// size: 20305 (min) 7778 (brotli)
1+
// size: 20366 (min) 7802 (brotli)
22
var empty = [],
33
rest = Symbol();
44
function attrTag(attrs) {
@@ -1219,48 +1219,47 @@ function _await_promise(nodeAccessor, params) {
12191219
},
12201220
}),
12211221
placeholderShown.add(pendingEffects),
1222-
!scope[promiseAccessor] &&
1223-
!awaitCounter.i++ &&
1224-
awaitBranch &&
1225-
((awaitBranch.T ||= []),
1226-
requestAnimationFrame(
1227-
() =>
1228-
awaitCounter.i &&
1229-
runEffects(
1230-
prepareEffects(() =>
1231-
queueRender(
1232-
tryBranch === awaitBranch ? scope : tryBranch,
1233-
() => {
1234-
tryBranch.Q
1235-
? (insertBranchBefore(
1236-
(tryBranch.P = createAndSetupBranch(
1237-
scope.$,
1238-
tryBranch.Q,
1239-
tryBranch._,
1222+
scope[promiseAccessor] ||
1223+
(awaitBranch && (awaitBranch.T ||= []),
1224+
awaitCounter.i++ ||
1225+
requestAnimationFrame(
1226+
() =>
1227+
awaitCounter.i &&
1228+
runEffects(
1229+
prepareEffects(() =>
1230+
queueRender(
1231+
tryBranch === awaitBranch ? scope : tryBranch,
1232+
() => {
1233+
tryBranch.Q
1234+
? (insertBranchBefore(
1235+
(tryBranch.P = createAndSetupBranch(
1236+
scope.$,
1237+
tryBranch.Q,
1238+
tryBranch._,
1239+
tryBranch.S.parentNode,
1240+
)),
12401241
tryBranch.S.parentNode,
1241-
)),
1242-
tryBranch.S.parentNode,
1243-
tryBranch.S,
1244-
),
1245-
tempDetachBranch(tryBranch))
1246-
: awaitBranch.V ||
1247-
(awaitBranch.S.parentNode.insertBefore(
1248-
scope[nodeAccessor],
1249-
awaitBranch.S,
1250-
),
1251-
tempDetachBranch(tryBranch));
1252-
},
1253-
-1,
1242+
tryBranch.S,
1243+
),
1244+
tempDetachBranch(tryBranch))
1245+
: awaitBranch.V ||
1246+
(awaitBranch.S.parentNode.insertBefore(
1247+
scope[nodeAccessor],
1248+
awaitBranch.S,
1249+
),
1250+
tempDetachBranch(tryBranch));
1251+
},
1252+
-1,
1253+
),
12541254
),
12551255
),
1256-
),
1257-
)));
1256+
)));
12581257
let thisPromise = (scope[promiseAccessor] = promise.then(
12591258
(data) => {
12601259
if (thisPromise === scope[promiseAccessor]) {
12611260
let referenceNode = scope[nodeAccessor];
12621261
((scope[promiseAccessor] = 0),
1263-
schedule(),
1262+
queueMicrotask(run),
12641263
queueRender(
12651264
scope,
12661265
() => {

.sizes/name-cache.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"vars":{"props":{"$empty":"e","$rest":"t","$attrTag":"n","$attrTags":"r","$attrTagIterator":"i","$_assert_hoist":"o","$forIn":"l","$forOf":"u","$forTo":"f","$forUntil":"a","$_call":"c","$stringifyClassObject":"s","$stringifyStyleObject":"d","$toDelimitedString":"h","$isEventHandler":"p","$getEventHandlerName":"g","$normalizeDynamicRenderer":"v","$decodeAccessor":"b","$toArray":"m","$push":"S","$defaultDelegator":"y","$_on":"A","$createDelegator":"N","$handleDelegated":"k","$stripSpacesAndPunctuation":"C","$nextScopeId":"_","$createScope":"w","$skipScope":"E","$findBranchWithKey":"T","$destroyBranch":"I","$destroyNestedBranches":"F","$removeAndDestroyBranch":"M","$insertBranchBefore":"x","$tempDetachBranch":"L","$walker":"$","$walk":"O","$walkInternal":"D","$branchesEnabled":"K","$isResuming":"V","$registeredValues":"G","$enableBranches":"R","$init":"B","$runResumeEffects":"H","$_resume":"U","$_var_resume":"q","$_el":"P","$_attr_input_checked":"j","$_attr_input_checked_script":"W","$_attr_input_checkedValue":"J","$_attr_input_checkedValue_script":"Q","$_attr_input_value":"X","$_attr_input_value_script":"Z","$_attr_select_value":"z","$_attr_select_value_script":"Y","$setSelectOptions":"ee","$_attr_details_or_dialog_open":"te","$_attr_details_or_dialog_open_script":"ne","$inputType":"re","$setValueAndUpdateSelection":"ie","$setCheckboxValue":"oe","$controllableDelegate":"le","$syncControllable":"ue","$handleChange":"fe","$handleFormReset":"ae","$hasValueChanged":"ce","$hasCheckboxChanged":"se","$hasSelectChanged":"de","$hasFormElementChanged":"he","$normalizeStrProp":"pe","$normalizeBoolProp":"ge","$toValueProp":"ve","$isScheduled":"be","$channel":"me","$parsers":"Se","$parseHTML":"ye","$schedule":"Ae","$flushAndWaitFrame":"Ne","$triggerMacroTask":"ke","$_let":"Ce","$_const":"_e","$_or":"we","$_for_closure":"Ee","$_if_closure":"Te","$subscribeToScopeSet":"Ie","$_closure":"Fe","$_closure_get":"Me","$_child_setup":"xe","$_var":"Le","$_return":"$e","$_return_change":"Oe","$_var_change":"De","$tagIdsByGlobal":"Ke","$_id":"Ve","$_script":"Ge","$_el_read":"Re","$traverseAllHoisted":"Be","$_hoist":"He","$createBranch":"Ue","$createAndSetupBranch":"qe","$setupBranch":"Pe","$_content":"je","$_content_resume":"We","$_content_closures":"Je","$cloneCache":"Qe","$_to_text":"Xe","$_attr":"Ze","$setAttribute":"ze","$_attr_class":"Ye","$_attr_class_items":"et","$_attr_class_item":"tt","$_attr_style":"nt","$_attr_style_items":"rt","$_attr_style_item":"it","$_text":"ot","$_text_content":"lt","$_attrs":"ut","$_attrs_content":"ft","$hasAttrAlias":"at","$_attrs_partial":"ct","$_attrs_partial_content":"st","$attrsInternal":"dt","$_attr_content":"ht","$_attrs_script":"pt","$_html":"gt","$normalizeAttrValue":"vt","$normalizeString":"bt","$_lifecycle":"mt","$removeChildNodes":"St","$insertChildNodes":"yt","$toInsertNode":"At","$_await_promise":"Nt","$_await_content":"kt","$_try":"Ct","$renderCatch":"_t","$_if":"wt","$_dynamic_tag":"Et","$_resume_dynamic_tag":"Tt","$dynamicTagScript":"It","$setConditionalRenderer":"Ft","$_for_of":"Mt","$_for_in":"xt","$_for_to":"Lt","$_for_until":"$t","$loop":"Ot","$createBranchWithTagNameOrRenderer":"Dt","$bySecondArg":"Kt","$byFirstArg":"Vt","$asyncRendersLookup":"Gt","$rendering":"Rt","$pendingRenders":"Bt","$pendingRendersLookup":"Ht","$caughtError":"Ut","$placeholderShown":"qt","$pendingEffects":"Pt","$pendingScopes":"jt","$scopeKeyOffset":"Wt","$queueRender":"Jt","$queuePendingRender":"Qt","$queueEffect":"Xt","$run":"Zt","$prepareEffects":"zt","$runEffects":"Yt","$runRenders":"en","$runRender":"tn","$_enable_catch":"nn","$$signalReset":"rn","$$signal":"on","$abort":"ln","$classIdToBranch":"un","$compat":"fn","$_template":"an","$mount":"cn","$$clickCount__script":"ta","$$clickCount":"aa","$$setup":"na","$forEach":"sn","$$if_content__setup":"sa","$$if_content__comment_comments":"ia","$$if_content__id":"ca","$$for_content__id":"la","$$for_content__input_path__OR__i":"ma","$$for_content__input_path":"oa","$$for_content__i":"ua","$$for_content__open__script":"ba","$$for_content__open":"ea","$$for_content__setup":"_a","$$for_content__comment_text":"da","$$for_content__if":"fa","$$for_content__comment_comments":"ha","$$for_content__$params":"ja","$$for_content__comment":"pa","$$for":"ra","$$input_comments":"ga","$$input_path":"ka"}}}
1+
{"vars":{"props":{"$empty":"e","$rest":"t","$attrTag":"n","$attrTags":"r","$attrTagIterator":"i","$_assert_hoist":"o","$forIn":"l","$forOf":"u","$forTo":"f","$forUntil":"a","$_call":"c","$stringifyClassObject":"s","$stringifyStyleObject":"d","$toDelimitedString":"h","$isEventHandler":"p","$getEventHandlerName":"g","$normalizeDynamicRenderer":"v","$decodeAccessor":"b","$toArray":"m","$push":"S","$defaultDelegator":"y","$_on":"A","$createDelegator":"N","$handleDelegated":"k","$stripSpacesAndPunctuation":"C","$nextScopeId":"_","$createScope":"w","$skipScope":"E","$findBranchWithKey":"T","$destroyBranch":"I","$destroyNestedBranches":"F","$removeAndDestroyBranch":"M","$insertBranchBefore":"x","$tempDetachBranch":"L","$walker":"$","$walk":"O","$walkInternal":"D","$branchesEnabled":"K","$isResuming":"V","$registeredValues":"G","$enableBranches":"R","$init":"B","$runResumeEffects":"H","$_resume":"U","$_var_resume":"q","$_el":"P","$_attr_input_checked":"j","$_attr_input_checked_script":"W","$_attr_input_checkedValue":"J","$_attr_input_checkedValue_script":"Q","$_attr_input_value":"X","$_attr_input_value_script":"Z","$_attr_select_value":"z","$_attr_select_value_script":"Y","$setSelectOptions":"ee","$_attr_details_or_dialog_open":"te","$_attr_details_or_dialog_open_script":"ne","$inputType":"re","$setValueAndUpdateSelection":"ie","$setCheckboxValue":"oe","$controllableDelegate":"le","$syncControllable":"ue","$handleChange":"fe","$handleFormReset":"ae","$hasValueChanged":"ce","$hasCheckboxChanged":"se","$hasSelectChanged":"de","$hasFormElementChanged":"he","$normalizeStrProp":"pe","$normalizeBoolProp":"ge","$toValueProp":"ve","$isScheduled":"be","$channel":"me","$parsers":"Se","$parseHTML":"ye","$schedule":"Ae","$flushAndWaitFrame":"Ne","$triggerMacroTask":"ke","$_let":"Ce","$_const":"_e","$_or":"we","$_for_closure":"Ee","$_if_closure":"Te","$subscribeToScopeSet":"Ie","$_closure":"Fe","$_closure_get":"Me","$_child_setup":"xe","$_var":"Le","$_return":"$e","$_return_change":"Oe","$_var_change":"De","$tagIdsByGlobal":"Ke","$_id":"Ve","$_script":"Ge","$_el_read":"Re","$traverseAllHoisted":"Be","$_hoist":"He","$createBranch":"Ue","$createAndSetupBranch":"qe","$setupBranch":"Pe","$_content":"je","$_content_resume":"We","$_content_closures":"Je","$cloneCache":"Qe","$_to_text":"Xe","$_attr":"Ze","$setAttribute":"ze","$_attr_class":"Ye","$_attr_class_items":"et","$_attr_class_item":"tt","$_attr_style":"nt","$_attr_style_items":"rt","$_attr_style_item":"it","$_text":"ot","$_text_content":"lt","$_attrs":"ut","$_attrs_content":"ft","$hasAttrAlias":"at","$_attrs_partial":"ct","$_attrs_partial_content":"st","$attrsInternal":"dt","$_attr_content":"ht","$_attrs_script":"pt","$_html":"gt","$normalizeAttrValue":"vt","$normalizeString":"bt","$_lifecycle":"mt","$removeChildNodes":"St","$insertChildNodes":"yt","$toInsertNode":"At","$_await_promise":"Nt","$_await_content":"kt","$_try":"Ct","$renderCatch":"_t","$_if":"wt","$_dynamic_tag":"Et","$_resume_dynamic_tag":"Tt","$dynamicTagScript":"It","$setConditionalRenderer":"Ft","$_for_of":"Mt","$_for_in":"xt","$_for_to":"Lt","$_for_until":"$t","$loop":"Ot","$createBranchWithTagNameOrRenderer":"Dt","$bySecondArg":"Kt","$byFirstArg":"Vt","$asyncRendersLookup":"Gt","$rendering":"Rt","$pendingRenders":"Bt","$pendingRendersLookup":"Ht","$caughtError":"Ut","$placeholderShown":"qt","$pendingEffects":"Pt","$pendingScopes":"jt","$scopeKeyOffset":"Wt","$queueRender":"Jt","$queuePendingRender":"Qt","$queueEffect":"Xt","$run":"Zt","$prepareEffects":"zt","$runEffects":"Yt","$runRenders":"en","$runRender":"tn","$_enable_catch":"nn","$$signalReset":"rn","$$signal":"on","$abort":"ln","$classIdToBranch":"un","$compat":"fn","$_template":"an","$mount":"cn","$$clickCount__script":"ta","$$clickCount":"aa","$$setup":"na","$forEach":"sn","$$if_content__setup":"sa","$$if_content__comment_comments":"ia","$$if_content__id":"ca","$$for_content__id":"la","$$for_content__input_path__OR__i":"ma","$$for_content__input_path":"oa","$$for_content__i":"ua","$$for_content__open__script":"ba","$$for_content__open":"ea","$$for_content__setup":"_a","$$for_content__comment_text":"da","$$for_content__if":"fa","$$for_content__comment_comments":"ha","$$for_content__$params":"ja","$$for_content__comment":"pa","$$for":"ra","$$input_comments":"ga","$$input_path":"ka","$_attr_nonce":"dn"}}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { wait } from "../../utils/resolve";
22

3-
export const steps = [{}, wait(1)];
3+
export const steps = [{}, wait()];

packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/dom.expected/tags/recurse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const $await_content = /* @__PURE__ */_._await_content("#text/0", `<!>${$templat
1414
const $try_content__await_promise = /* @__PURE__ */_._await_promise("#text/0");
1515
const $try_content__setup = $scope => {
1616
$await_content($scope);
17-
$try_content__await_promise($scope, resolveAfter(0, 1));
17+
$try_content__await_promise($scope, resolveAfter());
1818
};
1919
const $if_content__input_level = /* @__PURE__ */_._if_closure("#text/0", 0, $scope => _._attr($scope["#div/0"], "data-level", $scope._.input_level));
2020
const $if_content__try = /* @__PURE__ */_._try("#text/1", "<!><!><!>", /* over(1), replace, over(2) */"b%c", $try_content__setup);

packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/html.expected/tags/recurse.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const $content = input => {
1111
_._try($scope1_id, "#text/1", _._content_resume("__tests__/tags/recurse.marko_2_content", () => {
1212
const $scope2_id = _._scope_id();
1313
const $scope2_reason = _._scope_reason();
14-
_._await($scope2_id, "#text/0", resolveAfter(0, 1), () => {
14+
_._await($scope2_id, "#text/0", resolveAfter(), () => {
1515
const $scope3_id = _._scope_id();
1616
_._serialize_if($scope0_reason, /* input.level */0) && _._script($scope3_id, "__tests__/tags/recurse.marko_3_input_level");
1717
const $childScope = _._peek_scope_id();
@@ -23,12 +23,12 @@ const $content = input => {
2323
_: _._scope_with_id($scope2_id),
2424
"#childScope/0": _._serialize_if($scope0_reason, /* input.level */0) && _._existing_scope($childScope),
2525
"ClosureSignalIndex:input_level": _._serialize_if($scope0_reason, /* input.level */0) && 0
26-
}, "__tests__/tags/recurse.marko", "6:7");
26+
}, "__tests__/tags/recurse.marko", "7:7");
2727
_._resume_branch($scope3_id);
2828
}, _._serialize_guard($scope0_reason, /* input.level */0));
2929
_._serialize_if($scope0_reason, /* input.level */0) && _._scope($scope2_id, {
3030
_: _._scope_with_id($scope1_id)
31-
}, "__tests__/tags/recurse.marko", "4:5");
31+
}, "__tests__/tags/recurse.marko", "5:5");
3232
}, $scope1_id), {
3333
placeholder: _.attrTag({
3434
content: _._content_resume("__tests__/tags/recurse.marko_4_content", () => {
@@ -40,7 +40,7 @@ const $content = input => {
4040
_._html(`</div>${_._el_resume($scope1_id, "#div/0", _._serialize_guard($scope0_reason, /* input.level */0))}`);
4141
_._serialize_if($scope0_reason, /* input.level */0) && _._scope($scope1_id, {
4242
_: _._scope_with_id($scope0_id)
43-
}, "__tests__/tags/recurse.marko", "2:1");
43+
}, "__tests__/tags/recurse.marko", "3:1");
4444
return 0;
4545
}
4646
}, $scope0_id, "#text/0", _._serialize_guard($scope0_reason, /* input.level */0), _._serialize_guard($scope0_reason, /* input.level */0), _._serialize_guard($scope0_reason, /* input.level */0), 0, 1);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { resolveAfter } from "../../../utils/resolve";
2+
23
if=input.level
34
div data-level=input.level
45
try
56
@placeholder -- LOADING...
6-
await=resolveAfter(0, 1)
7+
await=resolveAfter()
78
recurse level=input.level - 1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { flush, wait } from "../../utils/resolve";
22

3-
export const steps = [{}, flush, flush, flush, flush, wait(5)];
3+
export const steps = [{}, flush, flush, flush, flush, wait()];

packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/dom.expected/template.hydrate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// size: 705 (min) 224 (brotli)
2-
const multiply = (multiplier, n) => resolveAfter(multiplier * n, n),
1+
// size: 703 (min) 222 (brotli)
2+
const multiply = (multiplier, n) => resolveAfter(multiplier * n),
33
$await_content5__result = _._const(2, ($scope) =>
44
_._text($scope.a, $scope.c),
55
),

packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/dom.expected/template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const $template = "<button>increment</button><p>1 * <!> = <!></p><p>2 * <!> = <!></p><p>3 * <!> = <!></p><p>4 * <!> = <!></p><p>5 * <!> = <!></p>";
22
export const $walks = /* get, over(1), next(1), over(1), replace, over(2), replace, out(1), next(1), over(1), replace, over(2), replace, out(1), next(1), over(1), replace, over(2), replace, out(1), next(1), over(1), replace, over(2), replace, out(1), next(1), over(1), replace, over(2), replace, out(1) */" bDb%c%lDb%c%lDb%c%lDb%c%lDb%c%l";
33
import { resolveAfter } from "../../utils/resolve";
4-
const multiply = (multiplier, n) => resolveAfter(multiplier * n, n);
4+
const multiply = (multiplier, n) => resolveAfter(multiplier * n);
55
import * as _ from "@marko/runtime-tags/debug/dom";
66
const $await_content5__result = /* @__PURE__ */_._const("result", $scope => _._text($scope["#text/0"], $scope.result));
77
const $await_content5__$params = /* @__PURE__ */_._const("$params6", $scope => $await_content5__result($scope, $scope.$params6[0]));

0 commit comments

Comments
 (0)