fix: prevent preview-tests race condition (#39286)
This commit is contained in:
committed by
GitHub
parent
fbdba9edb1
commit
de55527693
@ -40,14 +40,23 @@ import {
|
|||||||
|
|
||||||
// How long before bailing out of a preview.
|
// How long before bailing out of a preview.
|
||||||
const previewTimeout = 2500;
|
const previewTimeout = 2500;
|
||||||
|
let previewTask;
|
||||||
|
|
||||||
export function* executeCancellableChallengeSaga() {
|
export function* executeCancellableChallengeSaga() {
|
||||||
|
if (previewTask) {
|
||||||
|
yield cancel(previewTask);
|
||||||
|
}
|
||||||
const task = yield fork(executeChallengeSaga);
|
const task = yield fork(executeChallengeSaga);
|
||||||
|
previewTask = yield fork(previewChallengeSaga, { flushLogs: false });
|
||||||
|
|
||||||
yield take(types.cancelTests);
|
yield take(types.cancelTests);
|
||||||
yield cancel(task);
|
yield cancel(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function* executeCancellablePreviewSaga() {
|
||||||
|
previewTask = yield fork(previewChallengeSaga);
|
||||||
|
}
|
||||||
|
|
||||||
export function* executeChallengeSaga() {
|
export function* executeChallengeSaga() {
|
||||||
const isBuildEnabled = yield select(isBuildEnabledSelector);
|
const isBuildEnabled = yield select(isBuildEnabledSelector);
|
||||||
if (!isBuildEnabled) {
|
if (!isBuildEnabled) {
|
||||||
@ -157,7 +166,7 @@ function* executeTests(testRunner, tests, testTimeout = 5000) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// updates preview frame and the fcc console.
|
// updates preview frame and the fcc console.
|
||||||
function* previewChallengeSaga() {
|
function* previewChallengeSaga({ flushLogs = true } = {}) {
|
||||||
yield delay(700);
|
yield delay(700);
|
||||||
|
|
||||||
const isBuildEnabled = yield select(isBuildEnabledSelector);
|
const isBuildEnabled = yield select(isBuildEnabledSelector);
|
||||||
@ -169,8 +178,10 @@ function* previewChallengeSaga() {
|
|||||||
const proxyLogger = args => logProxy.put(args);
|
const proxyLogger = args => logProxy.put(args);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yield put(initLogs());
|
if (flushLogs) {
|
||||||
yield put(initConsole(''));
|
yield put(initLogs());
|
||||||
|
yield put(initConsole(''));
|
||||||
|
}
|
||||||
yield fork(takeEveryConsole, logProxy);
|
yield fork(takeEveryConsole, logProxy);
|
||||||
|
|
||||||
const challengeData = yield select(challengeDataSelector);
|
const challengeData = yield select(challengeDataSelector);
|
||||||
@ -212,7 +223,7 @@ export function createExecuteChallengeSaga(types) {
|
|||||||
types.challengeMounted,
|
types.challengeMounted,
|
||||||
types.resetChallenge
|
types.resetChallenge
|
||||||
],
|
],
|
||||||
previewChallengeSaga
|
executeCancellablePreviewSaga
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user