Skip to content

Commit

Permalink
Import executionAsyncId too
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Dec 16, 2023
1 parent 2ba9670 commit 52c924e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -23,6 +23,7 @@ export function initAsyncDebugInfo(): void {
},
promiseResolve(asyncId: number): void {
// TODO
executionAsyncId();
},
destroy(asyncId: number): void {
// TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export const supportsRequestStorage = true;
export const requestStorage: AsyncLocalStorage<Request> =
new AsyncLocalStorage();

export {createHook as createAsyncHook} from 'async_hooks';
export {createHook as createAsyncHook, executionAsyncId} from 'async_hooks';
export * from '../ReactFlightServerConfigDebugNode';
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export const supportsRequestStorage = true;
export const requestStorage: AsyncLocalStorage<Request> =
new AsyncLocalStorage();

export {createHook as createAsyncHook} from 'async_hooks';
export {createHook as createAsyncHook, executionAsyncId} from 'async_hooks';
export * from '../ReactFlightServerConfigDebugNode';
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export const supportsRequestStorage = true;
export const requestStorage: AsyncLocalStorage<Request> =
new AsyncLocalStorage();

export {createHook as createAsyncHook} from 'async_hooks';
export {createHook as createAsyncHook, executionAsyncId} from 'async_hooks';
export * from '../ReactFlightServerConfigDebugNode';
1 change: 1 addition & 0 deletions scripts/flow/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ declare class AsyncLocalStorage<T> {

declare var async_hooks: {
createHook(callbacks: any): any,
executionAsyncId(): number,
};

declare module 'node:worker_threads' {
Expand Down

0 comments on commit 52c924e

Please sign in to comment.