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
{{ message }}
Repository navigation
question, test: best way to retry async task #13346
I dislike 1 because it results in tests that are unreliable under load.
I like 2. People sometimes seem surprised when they see it, but it has yet to cause problems.
I don't have a problem with option 3 for the most part, but a potential issue with number 3 is that it makes tests unrunnable in older versions of Node.js. Often, when refactoring a test, I'll run it in an older version where it is expected to fail to make sure it still fails. This is not an issue for newer tests, of course.
Should we add a helper to common something like: common.tryUntil(block, pred)
where block can be a ((cb) => {})((ret) => if (pred(ret)) stop)
or an awaitable factory block().then((ret) => if (pred(ret)) stop)
Or we can document 2 as an idiom (and 3 is self explanatory)
Activity
Trott commentedon May 31, 2017
I dislike 1 because it results in tests that are unreliable under load.
I like 2. People sometimes seem surprised when they see it, but it has yet to cause problems.
I don't have a problem with option 3 for the most part, but a potential issue with number 3 is that it makes tests unrunnable in older versions of Node.js. Often, when refactoring a test, I'll run it in an older version where it is expected to fail to make sure it still fails. This is not an issue for newer tests, of course.
refack commentedon May 31, 2017
Should we add a helper to
commonsomething like:common.tryUntil(block, pred)where block can be a
((cb) => {})((ret) => if (pred(ret)) stop)or an awaitable factory
block().then((ret) => if (pred(ret)) stop)Or we can document 2 as an idiom (and 3 is self explanatory)
Trott commentedon May 31, 2017
I prefer documenting the idiom to a new helper function. My bar for adding yet more stuff to
commonis pretty high.Trott commentedon Aug 7, 2017
Should this remain open?
refack commentedon Aug 7, 2017
Closing, as this should be turned into PR.