mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
[Flight] Allow passing DEV only startTime as an option (#34912)
When you use the `createFromFetch` API we assume that the start time of the request is the same time as when you call `createFromFetch` but in principle you could use it with a Promise that starts earlier and just happens to resolve to a `Response`. When you use `createFromReadableStream` that is almost definitely the case. E.g. you might have started it way earlier and you don't call `createFromReadableStream` until you get the headers back (the fetch promise resolves). This adds an option to pass in the start time for debug purposes if you started the request before starting to parse it.
This commit is contained in:
parent
58bdc0bb96
commit
2cfb221937
|
|
@ -2561,6 +2561,7 @@ function ResponseInstance(
|
|||
findSourceMapURL: void | FindSourceMapURLCallback, // DEV-only
|
||||
replayConsole: boolean, // DEV-only
|
||||
environmentName: void | string, // DEV-only
|
||||
debugStartTime: void | number, // DEV-only
|
||||
debugChannel: void | DebugChannel, // DEV-only
|
||||
) {
|
||||
const chunks: Map<number, SomeChunk<any>> = new Map();
|
||||
|
|
@ -2621,7 +2622,8 @@ function ResponseInstance(
|
|||
// Note: createFromFetch allows this to be marked at the start of the fetch
|
||||
// where as if you use createFromReadableStream from the body of the fetch
|
||||
// then the start time is when the headers resolved.
|
||||
this._debugStartTime = performance.now();
|
||||
this._debugStartTime =
|
||||
debugStartTime == null ? performance.now() : debugStartTime;
|
||||
this._debugIOStarted = false;
|
||||
// We consider everything before the first setTimeout task to be cached data
|
||||
// and is not considered I/O required to load the stream.
|
||||
|
|
@ -2669,6 +2671,7 @@ export function createResponse(
|
|||
findSourceMapURL: void | FindSourceMapURLCallback, // DEV-only
|
||||
replayConsole: boolean, // DEV-only
|
||||
environmentName: void | string, // DEV-only
|
||||
debugStartTime: void | number, // DEV-only
|
||||
debugChannel: void | DebugChannel, // DEV-only
|
||||
): WeakResponse {
|
||||
return getWeakResponse(
|
||||
|
|
@ -2684,6 +2687,7 @@ export function createResponse(
|
|||
findSourceMapURL,
|
||||
replayConsole,
|
||||
environmentName,
|
||||
debugStartTime,
|
||||
debugChannel,
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ export function experimental_renderToHTML(
|
|||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
const streamState = createFlightStreamState(flightResponse, null);
|
||||
const flightDestination = {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ export type Options = {
|
|||
findSourceMapURL?: FindSourceMapURLCallback,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
};
|
||||
|
||||
function createDebugCallbackFromWritableStream(
|
||||
|
|
@ -103,6 +104,9 @@ function createResponseFromOptions(options: void | Options) {
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ export type Options = {
|
|||
findSourceMapURL?: FindSourceMapURLCallback,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
// For the Node.js client we only support a single-direction debug channel.
|
||||
debugChannel?: Readable,
|
||||
};
|
||||
|
|
@ -112,6 +113,9 @@ function createFromNodeStream<T>(
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,9 @@ function createResponseFromOptions(options: void | Options) {
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
}
|
||||
|
|
@ -205,6 +208,7 @@ export type Options = {
|
|||
temporaryReferences?: TemporaryReferenceSet,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
};
|
||||
|
||||
export function createFromReadableStream<T>(
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ export type Options = {
|
|||
temporaryReferences?: TemporaryReferenceSet,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
// For the Edge client we only support a single-direction debug channel.
|
||||
debugChannel?: {readable?: ReadableStream, ...},
|
||||
};
|
||||
|
|
@ -107,6 +108,9 @@ function createResponseFromOptions(options?: Options) {
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ export type Options = {
|
|||
encodeFormAction?: EncodeFormActionCallback,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
// For the Node.js client we only support a single-direction debug channel.
|
||||
debugChannel?: Readable,
|
||||
};
|
||||
|
|
@ -103,6 +104,9 @@ export function createFromNodeStream<T>(
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ export type Options = {
|
|||
findSourceMapURL?: FindSourceMapURLCallback,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
};
|
||||
|
||||
function createDebugCallbackFromWritableStream(
|
||||
|
|
@ -102,6 +103,9 @@ function createResponseFromOptions(options: void | Options) {
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ export type Options = {
|
|||
findSourceMapURL?: FindSourceMapURLCallback,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
// For the Edge client we only support a single-direction debug channel.
|
||||
debugChannel?: {readable?: ReadableStream, ...},
|
||||
};
|
||||
|
|
@ -109,6 +110,9 @@ function createResponseFromOptions(options: Options) {
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ export type Options = {
|
|||
findSourceMapURL?: FindSourceMapURLCallback,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
// For the Node.js client we only support a single-direction debug channel.
|
||||
debugChannel?: Readable,
|
||||
};
|
||||
|
|
@ -114,6 +115,9 @@ function createFromNodeStream<T>(
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ export type Options = {
|
|||
findSourceMapURL?: FindSourceMapURLCallback,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
};
|
||||
|
||||
function createDebugCallbackFromWritableStream(
|
||||
|
|
@ -102,6 +103,9 @@ function createResponseFromOptions(options: void | Options) {
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ export type Options = {
|
|||
findSourceMapURL?: FindSourceMapURLCallback,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
// For the Edge client we only support a single-direction debug channel.
|
||||
debugChannel?: {readable?: ReadableStream, ...},
|
||||
};
|
||||
|
|
@ -109,6 +110,9 @@ function createResponseFromOptions(options: Options) {
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ export type Options = {
|
|||
findSourceMapURL?: FindSourceMapURLCallback,
|
||||
replayConsoleLogs?: boolean,
|
||||
environmentName?: string,
|
||||
startTime?: number,
|
||||
// For the Node.js client we only support a single-direction debug channel.
|
||||
debugChannel?: Readable,
|
||||
};
|
||||
|
|
@ -114,6 +115,9 @@ function createFromNodeStream<T>(
|
|||
__DEV__ && options && options.environmentName
|
||||
? options.environmentName
|
||||
: undefined,
|
||||
__DEV__ && options && options.startTime != null
|
||||
? options.startTime
|
||||
: undefined,
|
||||
debugChannel,
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user