-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
SchedulerDOM falls back to globalThis if window is undefined #20865
SchedulerDOM falls back to globalThis if window is undefined #20865
Conversation
Comparing: c62986c...0182034 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
Is this fixing a regression, or adding a feature? In other words, did it not throw before? |
I haven't re-built and run the scheduling profiler in a while. My guess is that this broke with #20025 and we just hadn't noticed. |
I think before we were probably using the equivalent of SchedulerNoDOM, and this change now uses SchedulerDOM: https://github.com/facebook/react/pull/20025/files#diff-1b2464331bec5a14f0c1db975b4ea10aeaa2c4dccdec3c135a1d96faf0a1e57fL34 Probably the right call, but that's why the changes broke. We're using the DOM scheduler in an non-DOM environment. If we land this, we should probably rename this scheduler. |
I don't care about this specific fix. I was thinking of I'll dig in more to find out how the scheduling profiler ended up in this code path. |
In response to user feedback from @rickhanlonii, I recently made a small change to our scheduling profiler so that it stores lane labels in addition to numeric values (#20808).
While re-building the profiler UI to add the newly available info, I found that it throws when importing profiling data because of references to
window
(e.g.window.setTimeout
) inside ofSchedulerDOM
. (Some of the scheduling profiler code runs in a web worker andwindow
isn't defined there.)This PR adds a fallback to
globalThis
ifwindow
is not defined. It preferswindow
if available to minimize change. We could perhaps also workaround this by falling back to something else e.g.self
butglobalThis
seemed better.Thoughts?