Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settled: Ramp up timeout values for isSettled() check #262

Merged
merged 1 commit into from
Dec 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions addon-test-support/@ember/test-helpers/settled.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,28 @@ export function isSettled(options) {
return true;
}

const TIMEOUTS = [0, 1, 2, 5];
const MAX_TIMEOUT = 10;

export default function settled(options) {
return new EmberPromise(function(resolve) {
let watcher = global.setInterval(function() {
let settled = isSettled(options);
if (settled) {
// Stop polling
global.clearInterval(watcher);

// Synchronously resolve the promise
run(null, resolve);
function scheduleCheck(counter) {
let timeout = TIMEOUTS[counter];
if (timeout === undefined) {
timeout = MAX_TIMEOUT;
}
}, 10);

global.setTimeout(function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I think this is related to your timecop issue. I'll fix to use nextTick (which is captured eagerly much earlier) once #258 lands.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except, it's not: #245 (comment) 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should still be changed though, I agree

let settled = isSettled(options);
if (settled) {
// Synchronously resolve the promise
run(null, resolve);
} else {
scheduleCheck(counter + 1);
}
}, timeout);
}

scheduleCheck(0);
});
}