outer function component
@@ -32,7 +32,7 @@ Array [
]
`;
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should render children 1`] = `
+exports[`Profiler works in profiling and non-profiling bundles enableProfilerTimer:enabled should render children 1`] = `
outside span
@@ -46,75 +46,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTr
`;
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
+exports[`Profiler works in profiling and non-profiling bundles enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `
`;
+exports[`Profiler works in profiling and non-profiling bundles enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `
`;
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
-Array [
-
- outer function component
-
,
-
- inner class component
- ,
-
- inner span
- ,
-]
-`;
-
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should render children 1`] = `
-
-
- outside span
-
-
- inside span
-
-
- function component
-
-
-`;
-
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`;
-
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `
`;
-
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should support nested Profilers 1`] = `
-Array [
-
- outer function component
-
,
-
- inner class component
- ,
-
- inner span
- ,
-]
-`;
-
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should render children 1`] = `
-
-
- outside span
-
-
- inside span
-
-
- function component
-
-
-`;
-
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
-
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `
`;
-
-exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
+exports[`Profiler works in profiling and non-profiling bundles enableProfilerTimer:enabled should support nested Profilers 1`] = `
Array [
outer function component
diff --git a/packages/react/src/forks/ReactSharedInternals.umd.js b/packages/react/src/forks/ReactSharedInternals.umd.js
index 268b792da1e66..8082fd0eef033 100644
--- a/packages/react/src/forks/ReactSharedInternals.umd.js
+++ b/packages/react/src/forks/ReactSharedInternals.umd.js
@@ -7,7 +7,6 @@
import assign from 'object-assign';
import * as Scheduler from 'scheduler';
-import * as SchedulerTracing from 'scheduler/tracing';
import ReactCurrentDispatcher from '../ReactCurrentDispatcher';
import ReactCurrentOwner from '../ReactCurrentOwner';
import ReactDebugCurrentFrame from '../ReactDebugCurrentFrame';
@@ -28,7 +27,6 @@ const ReactSharedInternals = {
// This re-export is only required for UMD bundles;
// CJS bundles use the shared NPM package.
Scheduler,
- SchedulerTracing,
};
if (__DEV__) {
diff --git a/packages/scheduler/npm/tracing-profiling.js b/packages/scheduler/npm/tracing-profiling.js
deleted file mode 100644
index cb2d20c025226..0000000000000
--- a/packages/scheduler/npm/tracing-profiling.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-if (process.env.NODE_ENV === 'production') {
- module.exports = require('./cjs/scheduler-tracing.profiling.min.js');
-} else {
- module.exports = require('./cjs/scheduler-tracing.development.js');
-}
diff --git a/packages/scheduler/npm/tracing.js b/packages/scheduler/npm/tracing.js
deleted file mode 100644
index 1e318bd901b5d..0000000000000
--- a/packages/scheduler/npm/tracing.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-if (process.env.NODE_ENV === 'production') {
- module.exports = require('./cjs/scheduler-tracing.production.min.js');
-} else {
- module.exports = require('./cjs/scheduler-tracing.development.js');
-}
diff --git a/packages/scheduler/npm/umd/scheduler-tracing.development.js b/packages/scheduler/npm/umd/scheduler-tracing.development.js
deleted file mode 100644
index a81bf8fe2f98d..0000000000000
--- a/packages/scheduler/npm/umd/scheduler-tracing.development.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * @license React
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
-'use strict';
-
-(function(global, factory) {
- // eslint-disable-next-line no-unused-expressions
- typeof exports === 'object' && typeof module !== 'undefined'
- ? (module.exports = factory(require('react')))
- : typeof define === 'function' && define.amd // eslint-disable-line no-undef
- ? define(['react'], factory) // eslint-disable-line no-undef
- : (global.SchedulerTracing = factory(global));
-})(this, function(global) {
- function unstable_clear() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_clear.apply(
- this,
- arguments
- );
- }
-
- function unstable_getCurrent() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_getCurrent.apply(
- this,
- arguments
- );
- }
-
- function unstable_getThreadID() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_getThreadID.apply(
- this,
- arguments
- );
- }
-
- function unstable_subscribe() {
- // eslint-disable-next-line max-len
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_subscribe.apply(
- this,
- arguments
- );
- }
-
- function unstable_trace() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_trace.apply(
- this,
- arguments
- );
- }
-
- function unstable_unsubscribe() {
- // eslint-disable-next-line max-len
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_unsubscribe.apply(
- this,
- arguments
- );
- }
-
- function unstable_wrap() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_wrap.apply(
- this,
- arguments
- );
- }
-
- return Object.freeze({
- unstable_clear: unstable_clear,
- unstable_getCurrent: unstable_getCurrent,
- unstable_getThreadID: unstable_getThreadID,
- unstable_subscribe: unstable_subscribe,
- unstable_trace: unstable_trace,
- unstable_unsubscribe: unstable_unsubscribe,
- unstable_wrap: unstable_wrap,
- });
-});
diff --git a/packages/scheduler/npm/umd/scheduler-tracing.production.min.js b/packages/scheduler/npm/umd/scheduler-tracing.production.min.js
deleted file mode 100644
index a81bf8fe2f98d..0000000000000
--- a/packages/scheduler/npm/umd/scheduler-tracing.production.min.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * @license React
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
-'use strict';
-
-(function(global, factory) {
- // eslint-disable-next-line no-unused-expressions
- typeof exports === 'object' && typeof module !== 'undefined'
- ? (module.exports = factory(require('react')))
- : typeof define === 'function' && define.amd // eslint-disable-line no-undef
- ? define(['react'], factory) // eslint-disable-line no-undef
- : (global.SchedulerTracing = factory(global));
-})(this, function(global) {
- function unstable_clear() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_clear.apply(
- this,
- arguments
- );
- }
-
- function unstable_getCurrent() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_getCurrent.apply(
- this,
- arguments
- );
- }
-
- function unstable_getThreadID() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_getThreadID.apply(
- this,
- arguments
- );
- }
-
- function unstable_subscribe() {
- // eslint-disable-next-line max-len
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_subscribe.apply(
- this,
- arguments
- );
- }
-
- function unstable_trace() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_trace.apply(
- this,
- arguments
- );
- }
-
- function unstable_unsubscribe() {
- // eslint-disable-next-line max-len
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_unsubscribe.apply(
- this,
- arguments
- );
- }
-
- function unstable_wrap() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_wrap.apply(
- this,
- arguments
- );
- }
-
- return Object.freeze({
- unstable_clear: unstable_clear,
- unstable_getCurrent: unstable_getCurrent,
- unstable_getThreadID: unstable_getThreadID,
- unstable_subscribe: unstable_subscribe,
- unstable_trace: unstable_trace,
- unstable_unsubscribe: unstable_unsubscribe,
- unstable_wrap: unstable_wrap,
- });
-});
diff --git a/packages/scheduler/npm/umd/scheduler-tracing.profiling.min.js b/packages/scheduler/npm/umd/scheduler-tracing.profiling.min.js
deleted file mode 100644
index a81bf8fe2f98d..0000000000000
--- a/packages/scheduler/npm/umd/scheduler-tracing.profiling.min.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * @license React
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
-'use strict';
-
-(function(global, factory) {
- // eslint-disable-next-line no-unused-expressions
- typeof exports === 'object' && typeof module !== 'undefined'
- ? (module.exports = factory(require('react')))
- : typeof define === 'function' && define.amd // eslint-disable-line no-undef
- ? define(['react'], factory) // eslint-disable-line no-undef
- : (global.SchedulerTracing = factory(global));
-})(this, function(global) {
- function unstable_clear() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_clear.apply(
- this,
- arguments
- );
- }
-
- function unstable_getCurrent() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_getCurrent.apply(
- this,
- arguments
- );
- }
-
- function unstable_getThreadID() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_getThreadID.apply(
- this,
- arguments
- );
- }
-
- function unstable_subscribe() {
- // eslint-disable-next-line max-len
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_subscribe.apply(
- this,
- arguments
- );
- }
-
- function unstable_trace() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_trace.apply(
- this,
- arguments
- );
- }
-
- function unstable_unsubscribe() {
- // eslint-disable-next-line max-len
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_unsubscribe.apply(
- this,
- arguments
- );
- }
-
- function unstable_wrap() {
- return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing.unstable_wrap.apply(
- this,
- arguments
- );
- }
-
- return Object.freeze({
- unstable_clear: unstable_clear,
- unstable_getCurrent: unstable_getCurrent,
- unstable_getThreadID: unstable_getThreadID,
- unstable_subscribe: unstable_subscribe,
- unstable_trace: unstable_trace,
- unstable_unsubscribe: unstable_unsubscribe,
- unstable_wrap: unstable_wrap,
- });
-});
diff --git a/packages/scheduler/package.json b/packages/scheduler/package.json
index 04daf3e6a3133..e8ac46571b73b 100644
--- a/packages/scheduler/package.json
+++ b/packages/scheduler/package.json
@@ -25,8 +25,6 @@
"README.md",
"build-info.json",
"index.js",
- "tracing.js",
- "tracing-profiling.js",
"unstable_mock.js",
"unstable_no_dom.js",
"unstable_post_task.js",
diff --git a/packages/scheduler/src/Tracing.js b/packages/scheduler/src/Tracing.js
deleted file mode 100644
index cc71b03f9065f..0000000000000
--- a/packages/scheduler/src/Tracing.js
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @flow
- */
-
-import {enableSchedulerTracing} from 'shared/ReactFeatureFlags';
-
-export type Interaction = {|
- __count: number,
- id: number,
- name: string,
- timestamp: number,
-|};
-
-export type Subscriber = {
- // A new interaction has been created via the trace() method.
- onInteractionTraced: (interaction: Interaction) => void,
-
- // All scheduled async work for an interaction has finished.
- onInteractionScheduledWorkCompleted: (interaction: Interaction) => void,
-
- // New async work has been scheduled for a set of interactions.
- // When this work is later run, onWorkStarted/onWorkStopped will be called.
- // A batch of async/yieldy work may be scheduled multiple times before completing.
- // In that case, onWorkScheduled may be called more than once before onWorkStopped.
- // Work is scheduled by a "thread" which is identified by a unique ID.
- onWorkScheduled: (interactions: Set
, threadID: number) => void,
-
- // A batch of scheduled work has been canceled.
- // Work is done by a "thread" which is identified by a unique ID.
- onWorkCanceled: (interactions: Set, threadID: number) => void,
-
- // A batch of work has started for a set of interactions.
- // When this work is complete, onWorkStopped will be called.
- // Work is not always completed synchronously; yielding may occur in between.
- // A batch of async/yieldy work may also be re-started before completing.
- // In that case, onWorkStarted may be called more than once before onWorkStopped.
- // Work is done by a "thread" which is identified by a unique ID.
- onWorkStarted: (interactions: Set, threadID: number) => void,
-
- // A batch of work has completed for a set of interactions.
- // Work is done by a "thread" which is identified by a unique ID.
- onWorkStopped: (interactions: Set, threadID: number) => void,
- ...
-};
-
-export type InteractionsRef = {|current: Set|};
-
-export type SubscriberRef = {|current: Subscriber | null|};
-
-const DEFAULT_THREAD_ID = 0;
-
-// Counters used to generate unique IDs.
-let interactionIDCounter: number = 0;
-let threadIDCounter: number = 0;
-
-// Set of currently traced interactions.
-// Interactions "stack"–
-// Meaning that newly traced interactions are appended to the previously active set.
-// When an interaction goes out of scope, the previous set (if any) is restored.
-let interactionsRef: InteractionsRef = (null: any);
-
-// Listener(s) to notify when interactions begin and end.
-let subscriberRef: SubscriberRef = (null: any);
-
-if (enableSchedulerTracing) {
- interactionsRef = {
- current: new Set(),
- };
- subscriberRef = {
- current: null,
- };
-}
-
-export {interactionsRef as __interactionsRef, subscriberRef as __subscriberRef};
-
-export function unstable_clear(callback: Function): any {
- if (!enableSchedulerTracing) {
- return callback();
- }
-
- const prevInteractions = interactionsRef.current;
- interactionsRef.current = new Set();
-
- try {
- return callback();
- } finally {
- interactionsRef.current = prevInteractions;
- }
-}
-
-export function unstable_getCurrent(): Set | null {
- if (!enableSchedulerTracing) {
- return null;
- } else {
- return interactionsRef.current;
- }
-}
-
-export function unstable_getThreadID(): number {
- return ++threadIDCounter;
-}
-
-export function unstable_trace(
- name: string,
- timestamp: number,
- callback: Function,
- threadID: number = DEFAULT_THREAD_ID,
-): any {
- if (!enableSchedulerTracing) {
- return callback();
- }
-
- const interaction: Interaction = {
- __count: 1,
- id: interactionIDCounter++,
- name,
- timestamp,
- };
-
- const prevInteractions = interactionsRef.current;
-
- // Traced interactions should stack/accumulate.
- // To do that, clone the current interactions.
- // The previous set will be restored upon completion.
- const interactions = new Set(prevInteractions);
- interactions.add(interaction);
- interactionsRef.current = interactions;
-
- const subscriber = subscriberRef.current;
- let returnValue;
-
- try {
- if (subscriber !== null) {
- subscriber.onInteractionTraced(interaction);
- }
- } finally {
- try {
- if (subscriber !== null) {
- subscriber.onWorkStarted(interactions, threadID);
- }
- } finally {
- try {
- returnValue = callback();
- } finally {
- interactionsRef.current = prevInteractions;
-
- try {
- if (subscriber !== null) {
- subscriber.onWorkStopped(interactions, threadID);
- }
- } finally {
- interaction.__count--;
-
- // If no async work was scheduled for this interaction,
- // Notify subscribers that it's completed.
- if (subscriber !== null && interaction.__count === 0) {
- subscriber.onInteractionScheduledWorkCompleted(interaction);
- }
- }
- }
- }
- }
-
- return returnValue;
-}
-
-export function unstable_wrap(
- callback: Function,
- threadID: number = DEFAULT_THREAD_ID,
-): Function {
- if (!enableSchedulerTracing) {
- return callback;
- }
-
- const wrappedInteractions = interactionsRef.current;
-
- let subscriber = subscriberRef.current;
- if (subscriber !== null) {
- subscriber.onWorkScheduled(wrappedInteractions, threadID);
- }
-
- // Update the pending async work count for the current interactions.
- // Update after calling subscribers in case of error.
- wrappedInteractions.forEach(interaction => {
- interaction.__count++;
- });
-
- let hasRun = false;
-
- function wrapped() {
- const prevInteractions = interactionsRef.current;
- interactionsRef.current = wrappedInteractions;
-
- subscriber = subscriberRef.current;
-
- try {
- let returnValue;
-
- try {
- if (subscriber !== null) {
- subscriber.onWorkStarted(wrappedInteractions, threadID);
- }
- } finally {
- try {
- returnValue = callback.apply(undefined, arguments);
- } finally {
- interactionsRef.current = prevInteractions;
-
- if (subscriber !== null) {
- subscriber.onWorkStopped(wrappedInteractions, threadID);
- }
- }
- }
-
- return returnValue;
- } finally {
- if (!hasRun) {
- // We only expect a wrapped function to be executed once,
- // But in the event that it's executed more than once–
- // Only decrement the outstanding interaction counts once.
- hasRun = true;
-
- // Update pending async counts for all wrapped interactions.
- // If this was the last scheduled async work for any of them,
- // Mark them as completed.
- wrappedInteractions.forEach(interaction => {
- interaction.__count--;
-
- if (subscriber !== null && interaction.__count === 0) {
- subscriber.onInteractionScheduledWorkCompleted(interaction);
- }
- });
- }
- }
- }
-
- wrapped.cancel = function cancel() {
- subscriber = subscriberRef.current;
-
- try {
- if (subscriber !== null) {
- subscriber.onWorkCanceled(wrappedInteractions, threadID);
- }
- } finally {
- // Update pending async counts for all wrapped interactions.
- // If this was the last scheduled async work for any of them,
- // Mark them as completed.
- wrappedInteractions.forEach(interaction => {
- interaction.__count--;
-
- if (subscriber && interaction.__count === 0) {
- subscriber.onInteractionScheduledWorkCompleted(interaction);
- }
- });
- }
- };
-
- return wrapped;
-}
diff --git a/packages/scheduler/src/TracingSubscriptions.js b/packages/scheduler/src/TracingSubscriptions.js
deleted file mode 100644
index 9fd687adf415b..0000000000000
--- a/packages/scheduler/src/TracingSubscriptions.js
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @flow
- */
-
-import type {Interaction, Subscriber} from './Tracing';
-
-import {enableSchedulerTracing} from 'shared/ReactFeatureFlags';
-import {__subscriberRef} from './Tracing';
-
-let subscribers: Set = (null: any);
-if (enableSchedulerTracing) {
- subscribers = new Set();
-}
-
-export function unstable_subscribe(subscriber: Subscriber): void {
- if (enableSchedulerTracing) {
- subscribers.add(subscriber);
-
- if (subscribers.size === 1) {
- __subscriberRef.current = {
- onInteractionScheduledWorkCompleted,
- onInteractionTraced,
- onWorkCanceled,
- onWorkScheduled,
- onWorkStarted,
- onWorkStopped,
- };
- }
- }
-}
-
-export function unstable_unsubscribe(subscriber: Subscriber): void {
- if (enableSchedulerTracing) {
- subscribers.delete(subscriber);
-
- if (subscribers.size === 0) {
- __subscriberRef.current = null;
- }
- }
-}
-
-function onInteractionTraced(interaction: Interaction): void {
- let didCatchError = false;
- let caughtError = null;
-
- subscribers.forEach(subscriber => {
- try {
- subscriber.onInteractionTraced(interaction);
- } catch (error) {
- if (!didCatchError) {
- didCatchError = true;
- caughtError = error;
- }
- }
- });
-
- if (didCatchError) {
- throw caughtError;
- }
-}
-
-function onInteractionScheduledWorkCompleted(interaction: Interaction): void {
- let didCatchError = false;
- let caughtError = null;
-
- subscribers.forEach(subscriber => {
- try {
- subscriber.onInteractionScheduledWorkCompleted(interaction);
- } catch (error) {
- if (!didCatchError) {
- didCatchError = true;
- caughtError = error;
- }
- }
- });
-
- if (didCatchError) {
- throw caughtError;
- }
-}
-
-function onWorkScheduled(
- interactions: Set,
- threadID: number,
-): void {
- let didCatchError = false;
- let caughtError = null;
-
- subscribers.forEach(subscriber => {
- try {
- subscriber.onWorkScheduled(interactions, threadID);
- } catch (error) {
- if (!didCatchError) {
- didCatchError = true;
- caughtError = error;
- }
- }
- });
-
- if (didCatchError) {
- throw caughtError;
- }
-}
-
-function onWorkStarted(interactions: Set, threadID: number): void {
- let didCatchError = false;
- let caughtError = null;
-
- subscribers.forEach(subscriber => {
- try {
- subscriber.onWorkStarted(interactions, threadID);
- } catch (error) {
- if (!didCatchError) {
- didCatchError = true;
- caughtError = error;
- }
- }
- });
-
- if (didCatchError) {
- throw caughtError;
- }
-}
-
-function onWorkStopped(interactions: Set, threadID: number): void {
- let didCatchError = false;
- let caughtError = null;
-
- subscribers.forEach(subscriber => {
- try {
- subscriber.onWorkStopped(interactions, threadID);
- } catch (error) {
- if (!didCatchError) {
- didCatchError = true;
- caughtError = error;
- }
- }
- });
-
- if (didCatchError) {
- throw caughtError;
- }
-}
-
-function onWorkCanceled(
- interactions: Set,
- threadID: number,
-): void {
- let didCatchError = false;
- let caughtError = null;
-
- subscribers.forEach(subscriber => {
- try {
- subscriber.onWorkCanceled(interactions, threadID);
- } catch (error) {
- if (!didCatchError) {
- didCatchError = true;
- caughtError = error;
- }
- }
- });
-
- if (didCatchError) {
- throw caughtError;
- }
-}
diff --git a/packages/scheduler/src/__tests__/SchedulerUMDBundle-test.internal.js b/packages/scheduler/src/__tests__/SchedulerUMDBundle-test.internal.js
index d6dfeb2081e4a..fde4ee8af20e3 100644
--- a/packages/scheduler/src/__tests__/SchedulerUMDBundle-test.internal.js
+++ b/packages/scheduler/src/__tests__/SchedulerUMDBundle-test.internal.js
@@ -37,30 +37,10 @@ describe('Scheduling UMD bundle', () => {
global.MessageChannel = undefined;
});
- function filterPrivateKeys(name) {
- // Be very careful adding things to this filter!
- // It's easy to introduce bugs by doing it:
- // https://github.com/facebook/react/issues/14904
- switch (name) {
- case '__interactionsRef':
- case '__subscriberRef':
- // Don't forward these. (TODO: why?)
- return false;
- default:
- return true;
- }
- }
-
function validateForwardedAPIs(api, forwardedAPIs) {
- const apiKeys = Object.keys(api)
- .filter(filterPrivateKeys)
- .sort();
+ const apiKeys = Object.keys(api).sort();
forwardedAPIs.forEach(forwardedAPI => {
- expect(
- Object.keys(forwardedAPI)
- .filter(filterPrivateKeys)
- .sort(),
- ).toEqual(apiKeys);
+ expect(Object.keys(forwardedAPI).sort()).toEqual(apiKeys);
});
}
@@ -78,19 +58,4 @@ describe('Scheduling UMD bundle', () => {
secretAPI.Scheduler,
]);
});
-
- it('should define the same tracing API', () => {
- const api = require('../../tracing');
- const umdAPIDev = require('../../npm/umd/scheduler-tracing.development');
- const umdAPIProd = require('../../npm/umd/scheduler-tracing.production.min');
- const umdAPIProfiling = require('../../npm/umd/scheduler-tracing.profiling.min');
- const secretAPI = require('react/src/forks/ReactSharedInternals.umd')
- .default;
- validateForwardedAPIs(api, [
- umdAPIDev,
- umdAPIProd,
- umdAPIProfiling,
- secretAPI.SchedulerTracing,
- ]);
- });
});
diff --git a/packages/scheduler/src/__tests__/Tracing-test.internal.js b/packages/scheduler/src/__tests__/Tracing-test.internal.js
deleted file mode 100644
index 658b69313ca5b..0000000000000
--- a/packages/scheduler/src/__tests__/Tracing-test.internal.js
+++ /dev/null
@@ -1,375 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @jest-environment node
- */
-'use strict';
-
-describe('Tracing', () => {
- let SchedulerTracing;
- let ReactFeatureFlags;
-
- let advanceTimeBy;
- let currentTime;
-
- function loadModules({enableSchedulerTracing}) {
- jest.resetModules();
- jest.useFakeTimers();
-
- currentTime = 0;
- Date.now = jest.fn().mockImplementation(() => currentTime);
-
- advanceTimeBy = amount => {
- currentTime += amount;
- };
-
- ReactFeatureFlags = require('shared/ReactFeatureFlags');
- ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing;
-
- SchedulerTracing = require('scheduler/tracing');
- }
-
- describe('enableSchedulerTracing enabled', () => {
- beforeEach(() => loadModules({enableSchedulerTracing: true}));
-
- it('should return the value of a traced function', () => {
- expect(
- SchedulerTracing.unstable_trace('arbitrary', currentTime, () => 123),
- ).toBe(123);
- });
-
- it('should return the value of a clear function', () => {
- expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123);
- });
-
- it('should return the value of a wrapped function', () => {
- let wrapped;
- SchedulerTracing.unstable_trace('arbitrary', currentTime, () => {
- wrapped = SchedulerTracing.unstable_wrap(() => 123);
- });
- expect(wrapped()).toBe(123);
- });
-
- it('should pass arguments through to a wrapped function', done => {
- let wrapped;
- SchedulerTracing.unstable_trace('arbitrary', currentTime, () => {
- wrapped = SchedulerTracing.unstable_wrap((param1, param2) => {
- expect(param1).toBe('foo');
- expect(param2).toBe('bar');
- done();
- });
- });
- wrapped('foo', 'bar');
- });
-
- it('should return an empty set when outside of a traced event', () => {
- expect(SchedulerTracing.unstable_getCurrent()).toContainNoInteractions();
- });
-
- it('should report the traced interaction from within the trace callback', done => {
- advanceTimeBy(100);
-
- SchedulerTracing.unstable_trace('some event', currentTime, () => {
- const interactions = SchedulerTracing.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'some event', timestamp: 100},
- ]);
-
- done();
- });
- });
-
- it('should report the traced interaction from within wrapped callbacks', done => {
- let wrappedIndirection;
-
- function indirection() {
- const interactions = SchedulerTracing.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'some event', timestamp: 100},
- ]);
-
- done();
- }
-
- advanceTimeBy(100);
-
- SchedulerTracing.unstable_trace('some event', currentTime, () => {
- wrappedIndirection = SchedulerTracing.unstable_wrap(indirection);
- });
-
- advanceTimeBy(50);
-
- wrappedIndirection();
- });
-
- it('should clear the interaction stack for traced callbacks', () => {
- let innerTestReached = false;
-
- SchedulerTracing.unstable_trace('outer event', currentTime, () => {
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event'},
- ]);
-
- SchedulerTracing.unstable_clear(() => {
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions(
- [],
- );
-
- SchedulerTracing.unstable_trace('inner event', currentTime, () => {
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- {name: 'inner event'},
- ]);
-
- innerTestReached = true;
- });
- });
-
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event'},
- ]);
- });
-
- expect(innerTestReached).toBe(true);
- });
-
- it('should clear the interaction stack for wrapped callbacks', () => {
- let innerTestReached = false;
- let wrappedIndirection;
-
- const indirection = jest.fn(() => {
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event'},
- ]);
-
- SchedulerTracing.unstable_clear(() => {
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions(
- [],
- );
-
- SchedulerTracing.unstable_trace('inner event', currentTime, () => {
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- {name: 'inner event'},
- ]);
-
- innerTestReached = true;
- });
- });
-
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event'},
- ]);
- });
-
- SchedulerTracing.unstable_trace('outer event', currentTime, () => {
- wrappedIndirection = SchedulerTracing.unstable_wrap(indirection);
- });
-
- wrappedIndirection();
-
- expect(innerTestReached).toBe(true);
- });
-
- it('should support nested traced events', done => {
- advanceTimeBy(100);
-
- let innerIndirectionTraced = false;
- let outerIndirectionTraced = false;
-
- function innerIndirection() {
- const interactions = SchedulerTracing.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- {name: 'inner event', timestamp: 150},
- ]);
-
- innerIndirectionTraced = true;
- }
-
- function outerIndirection() {
- const interactions = SchedulerTracing.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- outerIndirectionTraced = true;
- }
-
- SchedulerTracing.unstable_trace('outer event', currentTime, () => {
- // Verify the current traced event
- let interactions = SchedulerTracing.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- advanceTimeBy(50);
-
- const wrapperOuterIndirection = SchedulerTracing.unstable_wrap(
- outerIndirection,
- );
-
- let wrapperInnerIndirection;
- let innerEventTraced = false;
-
- // Verify that a nested event is properly traced
- SchedulerTracing.unstable_trace('inner event', currentTime, () => {
- interactions = SchedulerTracing.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- {name: 'inner event', timestamp: 150},
- ]);
-
- // Verify that a wrapped outer callback is properly traced
- wrapperOuterIndirection();
- expect(outerIndirectionTraced).toBe(true);
-
- wrapperInnerIndirection = SchedulerTracing.unstable_wrap(
- innerIndirection,
- );
-
- innerEventTraced = true;
- });
-
- expect(innerEventTraced).toBe(true);
-
- // Verify that the original event is restored
- interactions = SchedulerTracing.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- // Verify that a wrapped nested callback is properly traced
- wrapperInnerIndirection();
- expect(innerIndirectionTraced).toBe(true);
-
- done();
- });
- });
-
- describe('error handling', () => {
- it('should reset state appropriately when an error occurs in a trace callback', done => {
- advanceTimeBy(100);
-
- SchedulerTracing.unstable_trace('outer event', currentTime, () => {
- expect(() => {
- SchedulerTracing.unstable_trace('inner event', currentTime, () => {
- throw Error('intentional');
- });
- }).toThrow();
-
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- done();
- });
- });
-
- it('should reset state appropriately when an error occurs in a wrapped callback', done => {
- advanceTimeBy(100);
-
- SchedulerTracing.unstable_trace('outer event', currentTime, () => {
- let wrappedCallback;
-
- SchedulerTracing.unstable_trace('inner event', currentTime, () => {
- wrappedCallback = SchedulerTracing.unstable_wrap(() => {
- throw Error('intentional');
- });
- });
-
- expect(wrappedCallback).toThrow();
-
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- done();
- });
- });
- });
-
- describe('advanced integration', () => {
- it('should return a unique threadID per request', () => {
- expect(SchedulerTracing.unstable_getThreadID()).not.toBe(
- SchedulerTracing.unstable_getThreadID(),
- );
- });
-
- it('should expose the current set of interactions to be externally manipulated', () => {
- SchedulerTracing.unstable_trace('outer event', currentTime, () => {
- expect(SchedulerTracing.__interactionsRef.current).toBe(
- SchedulerTracing.unstable_getCurrent(),
- );
-
- SchedulerTracing.__interactionsRef.current = new Set([
- {name: 'override event'},
- ]);
-
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- {name: 'override event'},
- ]);
- });
- });
-
- it('should expose a subscriber ref to be externally manipulated', () => {
- SchedulerTracing.unstable_trace('outer event', currentTime, () => {
- expect(SchedulerTracing.__subscriberRef).toEqual({
- current: null,
- });
- });
- });
- });
- });
-
- describe('enableSchedulerTracing disabled', () => {
- beforeEach(() => loadModules({enableSchedulerTracing: false}));
-
- it('should return the value of a traced function', () => {
- expect(
- SchedulerTracing.unstable_trace('arbitrary', currentTime, () => 123),
- ).toBe(123);
- });
-
- it('should return the value of a wrapped function', () => {
- let wrapped;
- SchedulerTracing.unstable_trace('arbitrary', currentTime, () => {
- wrapped = SchedulerTracing.unstable_wrap(() => 123);
- });
- expect(wrapped()).toBe(123);
- });
-
- it('should return null for traced interactions', () => {
- expect(SchedulerTracing.unstable_getCurrent()).toBe(null);
- });
-
- it('should execute traced callbacks', done => {
- SchedulerTracing.unstable_trace('some event', currentTime, () => {
- expect(SchedulerTracing.unstable_getCurrent()).toBe(null);
-
- done();
- });
- });
-
- it('should return the value of a clear function', () => {
- expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123);
- });
-
- it('should execute wrapped callbacks', done => {
- const wrappedCallback = SchedulerTracing.unstable_wrap(() => {
- expect(SchedulerTracing.unstable_getCurrent()).toBe(null);
-
- done();
- });
-
- wrappedCallback();
- });
-
- describe('advanced integration', () => {
- it('should not create unnecessary objects', () => {
- expect(SchedulerTracing.__interactionsRef).toBe(null);
- });
- });
- });
-});
diff --git a/packages/scheduler/src/__tests__/Tracing-test.js b/packages/scheduler/src/__tests__/Tracing-test.js
deleted file mode 100644
index 5259be4792560..0000000000000
--- a/packages/scheduler/src/__tests__/Tracing-test.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @jest-environment node
- */
-'use strict';
-
-describe('Tracing', () => {
- let SchedulerTracing;
-
- beforeEach(() => {
- jest.resetModules();
-
- SchedulerTracing = require('scheduler/tracing');
- });
-
- it('should return the value of a traced function', () => {
- expect(SchedulerTracing.unstable_trace('arbitrary', 0, () => 123)).toBe(
- 123,
- );
- });
-
- it('should return the value of a wrapped function', () => {
- let wrapped;
- SchedulerTracing.unstable_trace('arbitrary', 0, () => {
- wrapped = SchedulerTracing.unstable_wrap(() => 123);
- });
- expect(wrapped()).toBe(123);
- });
-
- it('should execute traced callbacks', done => {
- SchedulerTracing.unstable_trace('some event', 0, () => {
- done();
- });
- });
-
- it('should return the value of a clear function', () => {
- expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123);
- });
-
- it('should execute wrapped callbacks', done => {
- const wrappedCallback = SchedulerTracing.unstable_wrap(() => {
- done();
- });
-
- wrappedCallback();
- });
-});
diff --git a/packages/scheduler/src/__tests__/TracingSubscriptions-test.internal.js b/packages/scheduler/src/__tests__/TracingSubscriptions-test.internal.js
deleted file mode 100644
index 6eff59a6cf864..0000000000000
--- a/packages/scheduler/src/__tests__/TracingSubscriptions-test.internal.js
+++ /dev/null
@@ -1,621 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @jest-environment node
- */
-'use strict';
-
-describe('TracingSubscriptions', () => {
- let SchedulerTracing;
- let ReactFeatureFlags;
-
- let currentTime;
-
- let onInteractionScheduledWorkCompleted;
- let onInteractionTraced;
- let onWorkCanceled;
- let onWorkScheduled;
- let onWorkStarted;
- let onWorkStopped;
- let throwInOnInteractionScheduledWorkCompleted;
- let throwInOnInteractionTraced;
- let throwInOnWorkCanceled;
- let throwInOnWorkScheduled;
- let throwInOnWorkStarted;
- let throwInOnWorkStopped;
- let firstSubscriber;
- let secondSubscriber;
-
- const firstEvent = {id: 0, name: 'first', timestamp: 0};
- const secondEvent = {id: 1, name: 'second', timestamp: 0};
- const threadID = 123;
-
- function loadModules({enableSchedulerTracing, autoSubscribe = true}) {
- jest.resetModules();
- jest.useFakeTimers();
-
- currentTime = 0;
-
- ReactFeatureFlags = require('shared/ReactFeatureFlags');
- ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing;
-
- SchedulerTracing = require('scheduler/tracing');
-
- throwInOnInteractionScheduledWorkCompleted = false;
- throwInOnInteractionTraced = false;
- throwInOnWorkCanceled = false;
- throwInOnWorkScheduled = false;
- throwInOnWorkStarted = false;
- throwInOnWorkStopped = false;
-
- onInteractionScheduledWorkCompleted = jest.fn(() => {
- if (throwInOnInteractionScheduledWorkCompleted) {
- throw Error('Expected error onInteractionScheduledWorkCompleted');
- }
- });
- onInteractionTraced = jest.fn(() => {
- if (throwInOnInteractionTraced) {
- throw Error('Expected error onInteractionTraced');
- }
- });
- onWorkCanceled = jest.fn(() => {
- if (throwInOnWorkCanceled) {
- throw Error('Expected error onWorkCanceled');
- }
- });
- onWorkScheduled = jest.fn(() => {
- if (throwInOnWorkScheduled) {
- throw Error('Expected error onWorkScheduled');
- }
- });
- onWorkStarted = jest.fn(() => {
- if (throwInOnWorkStarted) {
- throw Error('Expected error onWorkStarted');
- }
- });
- onWorkStopped = jest.fn(() => {
- if (throwInOnWorkStopped) {
- throw Error('Expected error onWorkStopped');
- }
- });
-
- firstSubscriber = {
- onInteractionScheduledWorkCompleted,
- onInteractionTraced,
- onWorkCanceled,
- onWorkScheduled,
- onWorkStarted,
- onWorkStopped,
- };
-
- secondSubscriber = {
- onInteractionScheduledWorkCompleted: jest.fn(),
- onInteractionTraced: jest.fn(),
- onWorkCanceled: jest.fn(),
- onWorkScheduled: jest.fn(),
- onWorkStarted: jest.fn(),
- onWorkStopped: jest.fn(),
- };
-
- if (autoSubscribe) {
- SchedulerTracing.unstable_subscribe(firstSubscriber);
- SchedulerTracing.unstable_subscribe(secondSubscriber);
- }
- }
-
- describe('enabled', () => {
- beforeEach(() => loadModules({enableSchedulerTracing: true}));
-
- it('should lazily subscribe to tracing and unsubscribe again if there are no external subscribers', () => {
- loadModules({enableSchedulerTracing: true, autoSubscribe: false});
-
- expect(SchedulerTracing.__subscriberRef.current).toBe(null);
- SchedulerTracing.unstable_subscribe(firstSubscriber);
- expect(SchedulerTracing.__subscriberRef.current).toBeDefined();
- SchedulerTracing.unstable_subscribe(secondSubscriber);
- expect(SchedulerTracing.__subscriberRef.current).toBeDefined();
- SchedulerTracing.unstable_unsubscribe(secondSubscriber);
- expect(SchedulerTracing.__subscriberRef.current).toBeDefined();
- SchedulerTracing.unstable_unsubscribe(firstSubscriber);
- expect(SchedulerTracing.__subscriberRef.current).toBe(null);
- });
-
- describe('error handling', () => {
- it('should cover onInteractionTraced/onWorkStarted within', done => {
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- const mock = jest.fn();
-
- // It should call the callback before re-throwing
- throwInOnInteractionTraced = true;
- expect(() =>
- SchedulerTracing.unstable_trace(
- secondEvent.name,
- currentTime,
- mock,
- threadID,
- ),
- ).toThrow('Expected error onInteractionTraced');
- throwInOnInteractionTraced = false;
- expect(mock).toHaveBeenCalledTimes(1);
-
- throwInOnWorkStarted = true;
- expect(() =>
- SchedulerTracing.unstable_trace(
- secondEvent.name,
- currentTime,
- mock,
- threadID,
- ),
- ).toThrow('Expected error onWorkStarted');
- expect(mock).toHaveBeenCalledTimes(2);
-
- // It should restore the previous/outer interactions
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- firstEvent,
- ]);
-
- // It should call other subscribers despite the earlier error
- expect(secondSubscriber.onInteractionTraced).toHaveBeenCalledTimes(3);
- expect(secondSubscriber.onWorkStarted).toHaveBeenCalledTimes(3);
-
- done();
- });
- });
-
- it('should cover onWorkStopped within trace', done => {
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- let innerInteraction;
- const mock = jest.fn(() => {
- innerInteraction = Array.from(
- SchedulerTracing.unstable_getCurrent(),
- )[1];
- });
-
- throwInOnWorkStopped = true;
- expect(() =>
- SchedulerTracing.unstable_trace(
- secondEvent.name,
- currentTime,
- mock,
- ),
- ).toThrow('Expected error onWorkStopped');
- throwInOnWorkStopped = false;
-
- // It should restore the previous/outer interactions
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- firstEvent,
- ]);
-
- // It should update the interaction count so as not to interfere with subsequent calls
- expect(innerInteraction.__count).toBe(0);
-
- // It should call other subscribers despite the earlier error
- expect(secondSubscriber.onWorkStopped).toHaveBeenCalledTimes(1);
-
- done();
- });
- });
-
- it('should cover onInteractionScheduledWorkCompleted within trace', done => {
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- const mock = jest.fn();
-
- throwInOnInteractionScheduledWorkCompleted = true;
- expect(() =>
- SchedulerTracing.unstable_trace(
- secondEvent.name,
- currentTime,
- mock,
- ),
- ).toThrow('Expected error onInteractionScheduledWorkCompleted');
- throwInOnInteractionScheduledWorkCompleted = false;
-
- // It should restore the previous/outer interactions
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- firstEvent,
- ]);
-
- // It should call other subscribers despite the earlier error
- expect(
- secondSubscriber.onInteractionScheduledWorkCompleted,
- ).toHaveBeenCalledTimes(1);
-
- done();
- });
- });
-
- it('should cover the callback within trace', done => {
- expect(onWorkStarted).not.toHaveBeenCalled();
- expect(onWorkStopped).not.toHaveBeenCalled();
-
- expect(() => {
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- throw Error('Expected error callback');
- });
- }).toThrow('Expected error callback');
-
- expect(onWorkStarted).toHaveBeenCalledTimes(1);
- expect(onWorkStopped).toHaveBeenCalledTimes(1);
-
- done();
- });
-
- it('should cover onWorkScheduled within wrap', done => {
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- const interaction = Array.from(
- SchedulerTracing.unstable_getCurrent(),
- )[0];
- const beforeCount = interaction.__count;
-
- throwInOnWorkScheduled = true;
- expect(() => SchedulerTracing.unstable_wrap(() => {})).toThrow(
- 'Expected error onWorkScheduled',
- );
-
- // It should not update the interaction count so as not to interfere with subsequent calls
- expect(interaction.__count).toBe(beforeCount);
-
- // It should call other subscribers despite the earlier error
- expect(secondSubscriber.onWorkScheduled).toHaveBeenCalledTimes(1);
-
- done();
- });
- });
-
- it('should cover onWorkStarted within wrap', () => {
- const mock = jest.fn();
- let interaction, wrapped;
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0];
- wrapped = SchedulerTracing.unstable_wrap(mock);
- });
- expect(interaction.__count).toBe(1);
-
- throwInOnWorkStarted = true;
- expect(wrapped).toThrow('Expected error onWorkStarted');
-
- // It should call the callback before re-throwing
- expect(mock).toHaveBeenCalledTimes(1);
-
- // It should update the interaction count so as not to interfere with subsequent calls
- expect(interaction.__count).toBe(0);
-
- // It should call other subscribers despite the earlier error
- expect(secondSubscriber.onWorkStarted).toHaveBeenCalledTimes(2);
- });
-
- it('should cover onWorkStopped within wrap', done => {
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- const outerInteraction = Array.from(
- SchedulerTracing.unstable_getCurrent(),
- )[0];
- expect(outerInteraction.__count).toBe(1);
-
- let wrapped;
- let innerInteraction;
-
- SchedulerTracing.unstable_trace(secondEvent.name, currentTime, () => {
- innerInteraction = Array.from(
- SchedulerTracing.unstable_getCurrent(),
- )[1];
- expect(outerInteraction.__count).toBe(1);
- expect(innerInteraction.__count).toBe(1);
-
- wrapped = SchedulerTracing.unstable_wrap(jest.fn());
- expect(outerInteraction.__count).toBe(2);
- expect(innerInteraction.__count).toBe(2);
- });
-
- expect(outerInteraction.__count).toBe(2);
- expect(innerInteraction.__count).toBe(1);
-
- throwInOnWorkStopped = true;
- expect(wrapped).toThrow('Expected error onWorkStopped');
- throwInOnWorkStopped = false;
-
- // It should restore the previous interactions
- expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
- outerInteraction,
- ]);
-
- // It should update the interaction count so as not to interfere with subsequent calls
- expect(outerInteraction.__count).toBe(1);
- expect(innerInteraction.__count).toBe(0);
-
- expect(secondSubscriber.onWorkStopped).toHaveBeenCalledTimes(2);
-
- done();
- });
- });
-
- it('should cover the callback within wrap', done => {
- expect(onWorkStarted).not.toHaveBeenCalled();
- expect(onWorkStopped).not.toHaveBeenCalled();
-
- let wrapped;
- let interaction;
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0];
- wrapped = SchedulerTracing.unstable_wrap(() => {
- throw Error('Expected error wrap');
- });
- });
-
- expect(onWorkStarted).toHaveBeenCalledTimes(1);
- expect(onWorkStopped).toHaveBeenCalledTimes(1);
-
- expect(wrapped).toThrow('Expected error wrap');
-
- expect(onWorkStarted).toHaveBeenCalledTimes(2);
- expect(onWorkStopped).toHaveBeenCalledTimes(2);
- expect(onWorkStopped).toHaveBeenLastNotifiedOfWork([interaction]);
-
- done();
- });
-
- it('should cover onWorkCanceled within wrap', () => {
- let interaction, wrapped;
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0];
- wrapped = SchedulerTracing.unstable_wrap(jest.fn());
- });
- expect(interaction.__count).toBe(1);
-
- throwInOnWorkCanceled = true;
- expect(wrapped.cancel).toThrow('Expected error onWorkCanceled');
-
- expect(onWorkCanceled).toHaveBeenCalledTimes(1);
-
- // It should update the interaction count so as not to interfere with subsequent calls
- expect(interaction.__count).toBe(0);
- expect(
- onInteractionScheduledWorkCompleted,
- ).toHaveBeenLastNotifiedOfInteraction(firstEvent);
-
- // It should call other subscribers despite the earlier error
- expect(secondSubscriber.onWorkCanceled).toHaveBeenCalledTimes(1);
- });
- });
-
- it('calls lifecycle methods for trace', () => {
- expect(onInteractionTraced).not.toHaveBeenCalled();
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
-
- SchedulerTracing.unstable_trace(
- firstEvent.name,
- currentTime,
- () => {
- expect(onInteractionTraced).toHaveBeenCalledTimes(1);
- expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
- firstEvent,
- );
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
- expect(onWorkStarted).toHaveBeenCalledTimes(1);
- expect(onWorkStarted).toHaveBeenLastNotifiedOfWork(
- new Set([firstEvent]),
- threadID,
- );
- expect(onWorkStopped).not.toHaveBeenCalled();
-
- SchedulerTracing.unstable_trace(
- secondEvent.name,
- currentTime,
- () => {
- expect(onInteractionTraced).toHaveBeenCalledTimes(2);
- expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
- secondEvent,
- );
- expect(
- onInteractionScheduledWorkCompleted,
- ).not.toHaveBeenCalled();
- expect(onWorkStarted).toHaveBeenCalledTimes(2);
- expect(onWorkStarted).toHaveBeenLastNotifiedOfWork(
- new Set([firstEvent, secondEvent]),
- threadID,
- );
- expect(onWorkStopped).not.toHaveBeenCalled();
- },
- threadID,
- );
-
- expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
- expect(
- onInteractionScheduledWorkCompleted,
- ).toHaveBeenLastNotifiedOfInteraction(secondEvent);
- expect(onWorkStopped).toHaveBeenCalledTimes(1);
- expect(onWorkStopped).toHaveBeenLastNotifiedOfWork(
- new Set([firstEvent, secondEvent]),
- threadID,
- );
- },
- threadID,
- );
-
- expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);
- expect(
- onInteractionScheduledWorkCompleted,
- ).toHaveBeenLastNotifiedOfInteraction(firstEvent);
- expect(onWorkScheduled).not.toHaveBeenCalled();
- expect(onWorkCanceled).not.toHaveBeenCalled();
- expect(onWorkStarted).toHaveBeenCalledTimes(2);
- expect(onWorkStopped).toHaveBeenCalledTimes(2);
- expect(onWorkStopped).toHaveBeenLastNotifiedOfWork(
- new Set([firstEvent]),
- threadID,
- );
- });
-
- it('calls lifecycle methods for wrap', () => {
- const unwrapped = jest.fn();
- let wrapped;
-
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- expect(onInteractionTraced).toHaveBeenCalledTimes(1);
- expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
- firstEvent,
- );
-
- SchedulerTracing.unstable_trace(secondEvent.name, currentTime, () => {
- expect(onInteractionTraced).toHaveBeenCalledTimes(2);
- expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
- secondEvent,
- );
-
- wrapped = SchedulerTracing.unstable_wrap(unwrapped, threadID);
- expect(onWorkScheduled).toHaveBeenCalledTimes(1);
- expect(onWorkScheduled).toHaveBeenLastNotifiedOfWork(
- new Set([firstEvent, secondEvent]),
- threadID,
- );
- });
- });
-
- expect(onInteractionTraced).toHaveBeenCalledTimes(2);
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
-
- wrapped();
- expect(unwrapped).toHaveBeenCalled();
-
- expect(onWorkScheduled).toHaveBeenCalledTimes(1);
- expect(onWorkCanceled).not.toHaveBeenCalled();
- expect(onWorkStarted).toHaveBeenCalledTimes(3);
- expect(onWorkStarted).toHaveBeenLastNotifiedOfWork(
- new Set([firstEvent, secondEvent]),
- threadID,
- );
- expect(onWorkStopped).toHaveBeenCalledTimes(3);
- expect(onWorkStopped).toHaveBeenLastNotifiedOfWork(
- new Set([firstEvent, secondEvent]),
- threadID,
- );
-
- expect(
- onInteractionScheduledWorkCompleted.mock.calls[0][0],
- ).toMatchInteraction(firstEvent);
- expect(
- onInteractionScheduledWorkCompleted.mock.calls[1][0],
- ).toMatchInteraction(secondEvent);
- });
-
- it('should call the correct interaction subscriber methods when a wrapped callback is canceled', () => {
- const fnOne = jest.fn();
- const fnTwo = jest.fn();
- let wrappedOne, wrappedTwo;
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- wrappedOne = SchedulerTracing.unstable_wrap(fnOne, threadID);
- SchedulerTracing.unstable_trace(secondEvent.name, currentTime, () => {
- wrappedTwo = SchedulerTracing.unstable_wrap(fnTwo, threadID);
- });
- });
-
- expect(onInteractionTraced).toHaveBeenCalledTimes(2);
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
- expect(onWorkCanceled).not.toHaveBeenCalled();
- expect(onWorkStarted).toHaveBeenCalledTimes(2);
- expect(onWorkStopped).toHaveBeenCalledTimes(2);
-
- wrappedTwo.cancel();
-
- expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
- expect(
- onInteractionScheduledWorkCompleted,
- ).toHaveBeenLastNotifiedOfInteraction(secondEvent);
- expect(onWorkCanceled).toHaveBeenCalledTimes(1);
- expect(onWorkCanceled).toHaveBeenLastNotifiedOfWork(
- new Set([firstEvent, secondEvent]),
- threadID,
- );
-
- wrappedOne.cancel();
-
- expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);
- expect(
- onInteractionScheduledWorkCompleted,
- ).toHaveBeenLastNotifiedOfInteraction(firstEvent);
- expect(onWorkCanceled).toHaveBeenCalledTimes(2);
- expect(onWorkCanceled).toHaveBeenLastNotifiedOfWork(
- new Set([firstEvent]),
- threadID,
- );
-
- expect(fnOne).not.toHaveBeenCalled();
- expect(fnTwo).not.toHaveBeenCalled();
- });
-
- it('should not end an interaction twice if wrap is used to schedule follow up work within another wrap', () => {
- const fnOne = jest.fn(() => {
- wrappedTwo = SchedulerTracing.unstable_wrap(fnTwo, threadID);
- });
- const fnTwo = jest.fn();
- let wrappedOne, wrappedTwo;
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- wrappedOne = SchedulerTracing.unstable_wrap(fnOne, threadID);
- });
-
- expect(onInteractionTraced).toHaveBeenCalledTimes(1);
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
-
- wrappedOne();
-
- expect(onInteractionTraced).toHaveBeenCalledTimes(1);
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
-
- wrappedTwo();
-
- expect(onInteractionTraced).toHaveBeenCalledTimes(1);
- expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
- expect(
- onInteractionScheduledWorkCompleted,
- ).toHaveBeenLastNotifiedOfInteraction(firstEvent);
- });
-
- it('should not decrement the interaction count twice if a wrapped function is run twice', () => {
- const unwrappedOne = jest.fn();
- const unwrappedTwo = jest.fn();
- let wrappedOne, wrappedTwo;
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
- wrappedOne = SchedulerTracing.unstable_wrap(unwrappedOne, threadID);
- wrappedTwo = SchedulerTracing.unstable_wrap(unwrappedTwo, threadID);
- });
-
- expect(onInteractionTraced).toHaveBeenCalledTimes(1);
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
-
- wrappedOne();
-
- expect(unwrappedOne).toHaveBeenCalledTimes(1);
- expect(onInteractionTraced).toHaveBeenCalledTimes(1);
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
-
- wrappedOne();
-
- expect(unwrappedOne).toHaveBeenCalledTimes(2);
- expect(onInteractionTraced).toHaveBeenCalledTimes(1);
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
-
- wrappedTwo();
-
- expect(onInteractionTraced).toHaveBeenCalledTimes(1);
- expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
- expect(
- onInteractionScheduledWorkCompleted,
- ).toHaveBeenLastNotifiedOfInteraction(firstEvent);
- });
-
- it('should unsubscribe', () => {
- SchedulerTracing.unstable_unsubscribe(firstSubscriber);
- SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {});
-
- expect(onInteractionTraced).not.toHaveBeenCalled();
- });
- });
-
- describe('disabled', () => {
- beforeEach(() => loadModules({enableSchedulerTracing: false}));
-
- // TODO
- });
-});
diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js
index c8c2375babc90..757d9ab28b784 100644
--- a/packages/shared/ReactFeatureFlags.js
+++ b/packages/shared/ReactFeatureFlags.js
@@ -51,9 +51,6 @@ export const enableProfilerNestedUpdatePhase = false;
// This callback accepts the component type (class instance or function) the update is scheduled for.
export const enableProfilerNestedUpdateScheduledHook = false;
-// Trace which interactions trigger each commit.
-export const enableSchedulerTracing = __PROFILE__;
-
// Track which Fiber(s) schedule render work.
export const enableUpdaterTracking = __PROFILE__;
diff --git a/packages/shared/ReactTypes.js b/packages/shared/ReactTypes.js
index 19c89f77f9f12..03b70aae07e6d 100644
--- a/packages/shared/ReactTypes.js
+++ b/packages/shared/ReactTypes.js
@@ -155,8 +155,6 @@ export type MutableSource> = {|
// This doesn't require a value to be passed to either handler.
export interface Wakeable {
then(onFulfill: () => mixed, onReject: () => mixed): void | Wakeable;
- // Special flag to opt out of tracing interactions across a Suspense boundary.
- __reactDoNotTraceInteractions?: boolean;
}
// The subset of a Promise that React APIs rely on. This resolves a value.
diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js
index e712288cf11c3..ea9224d5a9445 100644
--- a/packages/shared/forks/ReactFeatureFlags.native-fb.js
+++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js
@@ -17,7 +17,6 @@ export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = false;
export const enableProfilerNestedUpdatePhase = false;
export const enableProfilerNestedUpdateScheduledHook = false;
-export const enableSchedulerTracing = __PROFILE__;
export const enableUpdaterTracking = false;
export const enableSuspenseServerRenderer = false;
export const enableSelectiveHydration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js
index 18375388be0a5..251bb310c1fb6 100644
--- a/packages/shared/forks/ReactFeatureFlags.native-oss.js
+++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js
@@ -19,7 +19,6 @@ export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = false;
export const enableProfilerNestedUpdatePhase = false;
export const enableProfilerNestedUpdateScheduledHook = false;
-export const enableSchedulerTracing = __PROFILE__;
export const enableUpdaterTracking = false;
export const enableSuspenseServerRenderer = false;
export const enableSelectiveHydration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js
index d7605e5ebb44e..aeee968922f12 100644
--- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js
+++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js
@@ -19,7 +19,6 @@ export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = false;
export const enableProfilerNestedUpdatePhase = false;
export const enableProfilerNestedUpdateScheduledHook = false;
-export const enableSchedulerTracing = __PROFILE__;
export const enableUpdaterTracking = false;
export const enableSuspenseServerRenderer = false;
export const enableSelectiveHydration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
index e3e4ea0f58a46..88f2287cd81b4 100644
--- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
+++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
@@ -19,7 +19,6 @@ export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = false;
export const enableProfilerNestedUpdatePhase = false;
export const enableProfilerNestedUpdateScheduledHook = false;
-export const enableSchedulerTracing = __PROFILE__;
export const enableUpdaterTracking = false;
export const enableSuspenseServerRenderer = false;
export const enableSelectiveHydration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
index 4d762c08277c3..5d43505fa1279 100644
--- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
@@ -19,7 +19,6 @@ export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = false;
export const enableProfilerNestedUpdatePhase = false;
export const enableProfilerNestedUpdateScheduledHook = false;
-export const enableSchedulerTracing = __PROFILE__;
export const enableUpdaterTracking = false;
export const enableSuspenseServerRenderer = false;
export const enableSelectiveHydration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.testing.js b/packages/shared/forks/ReactFeatureFlags.testing.js
index bd4137d3e7cb0..0edbfad4ab170 100644
--- a/packages/shared/forks/ReactFeatureFlags.testing.js
+++ b/packages/shared/forks/ReactFeatureFlags.testing.js
@@ -19,7 +19,6 @@ export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = false;
export const enableProfilerNestedUpdatePhase = false;
export const enableProfilerNestedUpdateScheduledHook = false;
-export const enableSchedulerTracing = __PROFILE__;
export const enableUpdaterTracking = false;
export const enableSuspenseServerRenderer = false;
export const enableSelectiveHydration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.testing.www.js b/packages/shared/forks/ReactFeatureFlags.testing.www.js
index dacb018e3bea6..98dbae4505e08 100644
--- a/packages/shared/forks/ReactFeatureFlags.testing.www.js
+++ b/packages/shared/forks/ReactFeatureFlags.testing.www.js
@@ -19,7 +19,6 @@ export const enableProfilerTimer = false;
export const enableProfilerCommitHooks = false;
export const enableProfilerNestedUpdatePhase = false;
export const enableProfilerNestedUpdateScheduledHook = false;
-export const enableSchedulerTracing = false;
export const enableUpdaterTracking = false;
export const enableSuspenseServerRenderer = true;
export const enableSelectiveHydration = true;
diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js
index 871d4cc48ff80..afae32b4082fb 100644
--- a/packages/shared/forks/ReactFeatureFlags.www.js
+++ b/packages/shared/forks/ReactFeatureFlags.www.js
@@ -55,7 +55,6 @@ export const enableSchedulingProfiler =
// Note: we'll want to remove this when we to userland implementation.
// For now, we'll turn it on for everyone because it's *already* on for everyone in practice.
// At least this will let us stop shipping implementation to all users.
-export const enableSchedulerTracing = true;
export const enableSchedulerDebugging = true;
export const warnAboutDeprecatedLifecycles = true;
diff --git a/packages/shared/forks/SchedulerTracing.umd.js b/packages/shared/forks/SchedulerTracing.umd.js
deleted file mode 100644
index 2fb835e95b89f..0000000000000
--- a/packages/shared/forks/SchedulerTracing.umd.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @flow
- */
-
-import * as React from 'react';
-
-const ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
-
-const {
- __interactionsRef,
- __subscriberRef,
- unstable_clear,
- unstable_getCurrent,
- unstable_getThreadID,
- unstable_subscribe,
- unstable_trace,
- unstable_unsubscribe,
- unstable_wrap,
-} = ReactInternals.SchedulerTracing;
-
-export {
- __interactionsRef,
- __subscriberRef,
- unstable_clear,
- unstable_getCurrent,
- unstable_getThreadID,
- unstable_subscribe,
- unstable_trace,
- unstable_unsubscribe,
- unstable_wrap,
-};
diff --git a/scripts/jest/matchers/interactionTracingMatchers.js b/scripts/jest/matchers/interactionTracingMatchers.js
deleted file mode 100644
index 8281d7d862eb5..0000000000000
--- a/scripts/jest/matchers/interactionTracingMatchers.js
+++ /dev/null
@@ -1,101 +0,0 @@
-'use strict';
-
-const jestDiff = require('jest-diff').default;
-
-function toContainNoInteractions(actualSet) {
- return {
- message: () =>
- this.isNot
- ? `Expected interactions but there were none.`
- : `Expected no interactions but there were ${actualSet.size}.`,
- pass: actualSet.size === 0,
- };
-}
-
-function toHaveBeenLastNotifiedOfInteraction(
- mockFunction,
- expectedInteraction
-) {
- const calls = mockFunction.mock.calls;
- if (calls.length === 0) {
- return {
- message: () => 'Mock function was not called',
- pass: false,
- };
- }
-
- const [actualInteraction] = calls[calls.length - 1];
-
- return toMatchInteraction(actualInteraction, expectedInteraction);
-}
-
-function toHaveBeenLastNotifiedOfWork(
- mockFunction,
- expectedInteractions,
- expectedThreadID = undefined
-) {
- const calls = mockFunction.mock.calls;
- if (calls.length === 0) {
- return {
- message: () => 'Mock function was not called',
- pass: false,
- };
- }
-
- const [actualInteractions, actualThreadID] = calls[calls.length - 1];
-
- if (expectedThreadID !== undefined) {
- if (expectedThreadID !== actualThreadID) {
- return {
- message: () => jestDiff(expectedThreadID + '', actualThreadID + ''),
- pass: false,
- };
- }
- }
-
- return toMatchInteractions(actualInteractions, expectedInteractions);
-}
-
-function toMatchInteraction(actual, expected) {
- let attribute;
- for (attribute in expected) {
- if (actual[attribute] !== expected[attribute]) {
- return {
- message: () => jestDiff(expected, actual),
- pass: false,
- };
- }
- }
-
- return {pass: true};
-}
-
-function toMatchInteractions(actualSetOrArray, expectedSetOrArray) {
- const actualArray = Array.from(actualSetOrArray);
- const expectedArray = Array.from(expectedSetOrArray);
-
- if (actualArray.length !== expectedArray.length) {
- return {
- message: () =>
- `Expected ${expectedArray.length} interactions but there were ${actualArray.length}`,
- pass: false,
- };
- }
-
- for (let i = 0; i < actualArray.length; i++) {
- const result = toMatchInteraction(actualArray[i], expectedArray[i]);
- if (result.pass === false) {
- return result;
- }
- }
-
- return {pass: true};
-}
-
-module.exports = {
- toContainNoInteractions,
- toHaveBeenLastNotifiedOfInteraction,
- toHaveBeenLastNotifiedOfWork,
- toMatchInteraction,
- toMatchInteractions,
-};
diff --git a/scripts/jest/matchers/profilerMatchers.js b/scripts/jest/matchers/profilerMatchers.js
index bc851ffd9e9e2..e69de29bb2d1d 100644
--- a/scripts/jest/matchers/profilerMatchers.js
+++ b/scripts/jest/matchers/profilerMatchers.js
@@ -1,72 +0,0 @@
-'use strict';
-
-const jestDiff = require('jest-diff').default;
-
-function toHaveLastRenderedWithNoInteractions(onRenderMockFn) {
- const calls = onRenderMockFn.mock.calls;
- if (calls.length === 0) {
- return {
- message: () => 'Mock onRender function was not called',
- pass: false,
- };
- }
-}
-
-function toHaveLastRenderedWithInteractions(
- onRenderMockFn,
- expectedInteractions
-) {
- const calls = onRenderMockFn.mock.calls;
- if (calls.length === 0) {
- return {
- message: () => 'Mock onRender function was not called',
- pass: false,
- };
- }
-
- const lastCall = calls[calls.length - 1];
- const actualInteractions = lastCall[6];
-
- return toMatchInteractions(actualInteractions, expectedInteractions);
-}
-
-function toMatchInteraction(actual, expected) {
- let attribute;
- for (attribute in expected) {
- if (actual[attribute] !== expected[attribute]) {
- return {
- message: () => jestDiff(expected, actual),
- pass: false,
- };
- }
- }
-
- return {pass: true};
-}
-
-function toMatchInteractions(actualSetOrArray, expectedSetOrArray) {
- const actualArray = Array.from(actualSetOrArray);
- const expectedArray = Array.from(expectedSetOrArray);
-
- if (actualArray.length !== expectedArray.length) {
- return {
- message: () =>
- `Expected ${expectedArray.length} interactions but there were ${actualArray.length}`,
- pass: false,
- };
- }
-
- for (let i = 0; i < actualArray.length; i++) {
- const result = toMatchInteraction(actualArray[i], expectedArray[i]);
- if (result.pass === false) {
- return result;
- }
- }
-
- return {pass: true};
-}
-
-module.exports = {
- toHaveLastRenderedWithInteractions,
- toHaveLastRenderedWithNoInteractions,
-};
diff --git a/scripts/jest/setupTests.js b/scripts/jest/setupTests.js
index 34f5633ea372e..abb358f817aa2 100644
--- a/scripts/jest/setupTests.js
+++ b/scripts/jest/setupTests.js
@@ -45,8 +45,6 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
}
expect.extend({
- ...require('./matchers/interactionTracingMatchers'),
- ...require('./matchers/profilerMatchers'),
...require('./matchers/toWarnDev'),
...require('./matchers/reactTestMatchers'),
});
diff --git a/scripts/jest/spec-equivalence-reporter/setupTests.js b/scripts/jest/spec-equivalence-reporter/setupTests.js
index 997abd76fb052..31814bb754d95 100644
--- a/scripts/jest/spec-equivalence-reporter/setupTests.js
+++ b/scripts/jest/spec-equivalence-reporter/setupTests.js
@@ -46,8 +46,6 @@ global.spyOnProd = function(...args) {
};
expect.extend({
- ...require('../matchers/interactionTracingMatchers'),
- ...require('../matchers/profilerMatchers'),
...require('../matchers/toWarnDev'),
...require('../matchers/reactTestMatchers'),
});
diff --git a/scripts/release/shared-commands/test-tracing-fixture.js b/scripts/release/shared-commands/test-tracing-fixture.js
deleted file mode 100644
index 781e4001472ea..0000000000000
--- a/scripts/release/shared-commands/test-tracing-fixture.js
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env node
-
-'use strict';
-
-const {join} = require('path');
-const puppeteer = require('puppeteer');
-const theme = require('../theme');
-const {logPromise} = require('../utils');
-
-const validate = async ({cwd}) => {
- const browser = await puppeteer.launch();
- const page = await browser.newPage();
-
- await page.goto(
- 'file://' + join(cwd, 'fixtures/tracing/index.html?puppeteer=true')
- );
-
- try {
- return await page.evaluate(() => {
- const button = document.getElementById('run-test-button');
- button.click();
-
- const items = document.querySelectorAll('[data-value]');
-
- if (items.length === 0) {
- return 'No results were found.';
- }
-
- for (let i = 0; i < items.length; i++) {
- const item = items[i];
- if (item.getAttribute('data-value') !== 'All checks pass') {
- return `Unexpected result, "${item.getAttribute('data-value')}"`;
- }
- }
-
- return null;
- });
- } finally {
- await browser.close();
- }
-};
-
-const run = async ({cwd}) => {
- const errorMessage = await logPromise(
- validate({cwd}),
- 'Verifying "scheduler/tracing" fixture'
- );
- if (errorMessage) {
- console.error(
- theme.error('✗'),
- 'Verifying "scheduler/tracing" fixture\n ',
- theme.error(errorMessage)
- );
- process.exit(1);
- }
-};
-
-module.exports = run;
diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js
index 2890c5518104e..b34c0077873a6 100644
--- a/scripts/rollup/bundles.js
+++ b/scripts/rollup/bundles.js
@@ -805,24 +805,6 @@ const bundles = [
global: 'ReactFreshRuntime',
externals: [],
},
-
- {
- bundleTypes: [
- FB_WWW_DEV,
- FB_WWW_PROD,
- FB_WWW_PROFILING,
- NODE_DEV,
- NODE_PROD,
- NODE_PROFILING,
- RN_FB_DEV,
- RN_FB_PROD,
- RN_FB_PROFILING,
- ],
- moduleType: ISOMORPHIC,
- entry: 'scheduler/tracing',
- global: 'SchedulerTracing',
- externals: [],
- },
];
// Based on deep-freeze by substack (public domain)
diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js
index 2c64c6219e35d..84211da5c5125 100644
--- a/scripts/rollup/forks.js
+++ b/scripts/rollup/forks.js
@@ -171,25 +171,6 @@ const forks = Object.freeze({
}
},
- 'scheduler/tracing': (bundleType, entry, dependencies) => {
- switch (bundleType) {
- case UMD_DEV:
- case UMD_PROD:
- case UMD_PROFILING:
- if (dependencies.indexOf('react') === -1) {
- // It's only safe to use this fork for modules that depend on React,
- // because they read the re-exported API from the SECRET_INTERNALS object.
- return null;
- }
- // Optimization: for UMDs, use the API that is already a part of the React
- // package instead of requiring it to be loaded via a separate