You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above config defines 3 functions for each of preProcess and postProcess:
One defined as an async function, which resolves after a 1-second delay
One defined as a function that returns a promise, which resolves after a 1-second delay (the same behavior as the first function, just defined differently)
One defined as a function that returns immediately
Expected Behavior
Based on the documentation (which states functions run in order), I expect this:
pre async
pre promise
pre sync
post async
post promise
post sync
Actual Behavior
What actually happens is this:
14:18:39.971 pre sync
14:18:40.979 pre async
14:18:40.980 pre promise
14:18:41.119 post sync
14:18:42.119 post async
14:18:42.120 post promise
(Timestamps are included above to demonstrate that the async functions finish around a second after the sync function starts, indicating they start around the same time, given the async functions' 1-second wait time.)
Root Cause
This occurs because the implementations for both properties use Promise.all on a mapped array which has already immediately invoked each function up-front. To preserve order, these functions' invocations would need to be sequentially chained instead.
Aside: It is worth noting that the documentation itself does not seem to explicitly indicate that preProcess and postProcess support promises; it seems it was never updated when that functionality was added.
I would be interested in working on a PR to fix this if one would be accepted. (Edit: I initially had problems getting tests to run, but forcing karma to run with --browsers Firefox helped in my case, since I don't have Chrome installed on this machine.)
The text was updated successfully, but these errors were encountered:
Description of problem
Given the following
preProcess
andpostProcess
examples within a respec config:The above config defines 3 functions for each of
preProcess
andpostProcess
:Expected Behavior
Based on the documentation (which states functions run in order), I expect this:
Actual Behavior
What actually happens is this:
(Timestamps are included above to demonstrate that the async functions finish around a second after the sync function starts, indicating they start around the same time, given the async functions' 1-second wait time.)
Root Cause
This occurs because the implementations for both properties use
Promise.all
on a mapped array which has already immediately invoked each function up-front. To preserve order, these functions' invocations would need to be sequentially chained instead.Aside: It is worth noting that the documentation itself does not seem to explicitly indicate that
preProcess
andpostProcess
support promises; it seems it was never updated when that functionality was added.I would be interested in working on a PR to fix this if one would be accepted. (Edit: I initially had problems getting tests to run, but forcing karma to run with
--browsers Firefox
helped in my case, since I don't have Chrome installed on this machine.)The text was updated successfully, but these errors were encountered: