mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
This wires up the use of `async_hooks` in the Node build (as well as the Edge build when a global is available) in DEV mode only. This will be used to track debug info about what suspended during an RSC pass. Enabled behind a flag for now.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and 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 {createAsyncHook, executionAsyncId} from './ReactFlightServerConfig';
|
|
import {enableAsyncDebugInfo} from 'shared/ReactFeatureFlags';
|
|
|
|
// Initialize the tracing of async operations.
|
|
// We do this globally since the async work can potentially eagerly
|
|
// start before the first request and once requests start they can interleave.
|
|
// In theory we could enable and disable using a ref count of active requests
|
|
// but given that typically this is just a live server, it doesn't really matter.
|
|
export function initAsyncDebugInfo(): void {
|
|
if (__DEV__ && enableAsyncDebugInfo) {
|
|
createAsyncHook({
|
|
init(asyncId: number, type: string, triggerAsyncId: number): void {
|
|
// TODO
|
|
},
|
|
promiseResolve(asyncId: number): void {
|
|
// TODO
|
|
executionAsyncId();
|
|
},
|
|
destroy(asyncId: number): void {
|
|
// TODO
|
|
},
|
|
}).enable();
|
|
}
|
|
}
|