From 52c924e90a853ed049d47f99df19da999578e566 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Fri, 15 Dec 2023 19:48:53 -0500 Subject: [PATCH] Import executionAsyncId too --- packages/react-server/src/ReactFlightServerConfigDebugNode.js | 3 ++- .../src/forks/ReactFlightServerConfig.dom-edge-turbopack.js | 2 ++ .../react-server/src/forks/ReactFlightServerConfig.dom-edge.js | 2 ++ .../src/forks/ReactFlightServerConfig.dom-node-esm.js | 2 +- .../src/forks/ReactFlightServerConfig.dom-node-turbopack.js | 2 +- .../react-server/src/forks/ReactFlightServerConfig.dom-node.js | 2 +- scripts/flow/environment.js | 1 + 7 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/react-server/src/ReactFlightServerConfigDebugNode.js b/packages/react-server/src/ReactFlightServerConfigDebugNode.js index 81723ed514c7b..f9f4d9cef3f89 100644 --- a/packages/react-server/src/ReactFlightServerConfigDebugNode.js +++ b/packages/react-server/src/ReactFlightServerConfigDebugNode.js @@ -7,7 +7,7 @@ * @flow */ -import {createAsyncHook} from './ReactFlightServerConfig'; +import {createAsyncHook, executionAsyncId} from './ReactFlightServerConfig'; import {enableAsyncDebugInfo} from 'shared/ReactFeatureFlags'; // Initialize the tracing of async operations. @@ -23,6 +23,7 @@ export function initAsyncDebugInfo(): void { }, promiseResolve(asyncId: number): void { // TODO + executionAsyncId(); }, destroy(asyncId: number): void { // TODO diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-turbopack.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-turbopack.js index 9f34ae0ed8bde..64a329a341f11 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-turbopack.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-turbopack.js @@ -28,4 +28,6 @@ export const createAsyncHook: HookCallbacks => AsyncHook = disable() {}, }: any); }; +export const executionAsyncId: () => number = + typeof async_hooks === 'object' ? async_hooks.executionAsyncId : (null: any); export * from '../ReactFlightServerConfigDebugNode'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge.js index e0589c54f14e6..b15e88ed11e46 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge.js @@ -28,4 +28,6 @@ export const createAsyncHook: HookCallbacks => AsyncHook = disable() {}, }: any); }; +export const executionAsyncId: () => number = + typeof async_hooks === 'object' ? async_hooks.executionAsyncId : (null: any); export * from '../ReactFlightServerConfigDebugNode'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-esm.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-esm.js index 07dc08dd41887..f3460fd71b925 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-esm.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-esm.js @@ -17,5 +17,5 @@ export const supportsRequestStorage = true; export const requestStorage: AsyncLocalStorage = new AsyncLocalStorage(); -export {createHook as createAsyncHook} from 'async_hooks'; +export {createHook as createAsyncHook, executionAsyncId} from 'async_hooks'; export * from '../ReactFlightServerConfigDebugNode'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-turbopack.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-turbopack.js index 5f9f969da7ea9..d9eb6a46e4e71 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-turbopack.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-turbopack.js @@ -18,5 +18,5 @@ export const supportsRequestStorage = true; export const requestStorage: AsyncLocalStorage = new AsyncLocalStorage(); -export {createHook as createAsyncHook} from 'async_hooks'; +export {createHook as createAsyncHook, executionAsyncId} from 'async_hooks'; export * from '../ReactFlightServerConfigDebugNode'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js index 0970895eed357..d716d502f7598 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js @@ -18,5 +18,5 @@ export const supportsRequestStorage = true; export const requestStorage: AsyncLocalStorage = new AsyncLocalStorage(); -export {createHook as createAsyncHook} from 'async_hooks'; +export {createHook as createAsyncHook, executionAsyncId} from 'async_hooks'; export * from '../ReactFlightServerConfigDebugNode'; diff --git a/scripts/flow/environment.js b/scripts/flow/environment.js index cf06bca2a5c3b..19adb73dd7334 100644 --- a/scripts/flow/environment.js +++ b/scripts/flow/environment.js @@ -322,6 +322,7 @@ declare class AsyncLocalStorage { declare var async_hooks: { createHook(callbacks: any): any, + executionAsyncId(): number, }; declare module 'node:worker_threads' {