facebook/react · error · Error
While flushing work, something yielded a value. Use an asser
Error message
While flushing work, something yielded a value. Use an assertion helper to assert on the log of yielded values, e.g. expect(Scheduler).toFlushAndYield([...])
What it means
unstable_flushAll() re-checks the yielded-value log after draining all queued work; if any task called Scheduler.log(value) during the flush it throws 'While flushing work, something yielded a value...'. The mock insists that tests which produce logged values declare them via an assertion helper such as expect(Scheduler).toFlushAndYield([...]) instead of a bare flush that would silently discard them.
Source
Thrown at packages/scheduler/src/forks/SchedulerMock.js:619
function unstable_clearLog(): Array<mixed> {
if (yieldedValues === null) {
return [];
}
const values = yieldedValues;
yieldedValues = null;
return values;
}
function unstable_flushAll(): void {
if (yieldedValues !== null) {
throw new Error(
'Log is not empty. Assert on the log of yielded values before ' +
'flushing additional work.',
);
}
unstable_flushAllWithoutAsserting();
if (yieldedValues !== null) {
throw new Error(
'While flushing work, something yielded a value. Use an ' +
'assertion helper to assert on the log of yielded values, e.g. ' +
'expect(Scheduler).toFlushAndYield([...])',
);
}
}
function log(value: mixed): void {
// eslint-disable-next-line react-internal/no-production-logging
if (console.log.name === 'disabledLog' || disableYieldValue) {
// If console.log has been patched, we assume we're in render
// replaying and we ignore any values yielding in the second pass.
return;
}
if (yieldedValues === null) {
yieldedValues = [value];
} else {
yieldedValues.push(value);View on GitHub (pinned to eafeac097b)
Solutions
- Replace the bare flush with expect(Scheduler).toFlushAndYield([...]) listing exactly the values the tasks log.
- If the values are irrelevant, use unstable_flushAllWithoutAsserting() (optionally followed by unstable_clearLog()) instead of unstable_flushAll().
- Use toFlushAndYieldThrough([...]) when only a prefix of the logged values is deterministic.
- Delete stray Scheduler.log() calls left in shared helpers.
Example fix
// before
Scheduler.scheduleCallback(NormalPriority, () => Scheduler.log('hi'));
Scheduler.unstable_flushAll(); // throws: something yielded a value
// after
Scheduler.scheduleCallback(NormalPriority, () => Scheduler.log('hi'));
expect(Scheduler).toFlushAndYield(['hi']); Defensive patterns
Strategy: validation
Validate before calling
// If you do not intend to assert values, use the non-asserting variant up front. Scheduler.unstable_flushAllWithoutAsserting(); // never throws on yielded values Scheduler.unstable_clearLog(); // discard whatever was logged // otherwise declare expectations explicitly: // expect(Scheduler).toFlushAndYield(['a', 'b']);
Try / catch
try {
Scheduler.unstable_flushAll();
} catch (e) {
if (e instanceof Error && e.message.includes('something yielded a value')) {
Scheduler.unstable_clearLog();
Scheduler.unstable_flushAllWithoutAsserting(); // re-flush without the strict check
} else {
throw e;
}
} Prevention
- Whenever scheduled tasks call Scheduler.log(), assert with toFlushAndYield([...]) instead of unstable_flushAll().
- Use toFlushAndYieldThrough for non-deterministic suffixes.
- Remove stray log() calls from shared task helpers so strict flushes stay usable.
When it happens
Trigger: Calling Scheduler.unstable_flushAll() when the tasks scheduled in the test call Scheduler.log(...) — the do-while loop appends the values to yieldedValues and the post-flush check finds a non-null log.
Common situations: New tests modeled on React fixture tests where tasks log values; conditional logging that only fires for certain inputs; a leftover Scheduler.log() call inside a shared task helper copied from an older fixture.
Related errors
- Log is not empty. Assert on the log of yielded values before
- Cannot reset while already flushing work.
- Already flushing work.
- react-dom/unstable_testing is not supported in React Server
- 361
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/9618c72c67eb82c5.
Report an issue: GitHub.