Skip to content

fix(flushMicroTasks): Fallback to no scheduler in case of exception #739

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

Merged
Merged
Changes from 2 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
13 changes: 12 additions & 1 deletion src/flush-microtasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function getIsUsingFakeTimers() {

const globalObj = typeof window === 'undefined' ? global : window
let Scheduler = globalObj.Scheduler
const isModernScheduleCallbackSupported = satisfies(React.version, '>16.8.6', {
let isModernScheduleCallbackSupported = satisfies(React.version, '>16.8.6', {
includePrerelease: true,
})

Expand Down Expand Up @@ -58,6 +58,17 @@ try {
'if you encounter this warning.',
)
}

if (isModernScheduleCallbackSupported) {
// eslint-disable-next-line no-console
console.error(
'This environment does not support module requiring, so we cannot require the Scheduler. ' +
'To fix this you can require the Scheduler in your test setup file.',
)

// Fallback to no scheduleCallback Supported.
isModernScheduleCallbackSupported = false
}
}
}

Expand Down