1919
if (awaited !== null) {
1920
const ioNode = visitAsyncNode(request, task, awaited, cutOff, visited);
1921
if (ioNode !== null) {
1922
+ if (node.end < 0) {
1923
+ // If we haven't defined an end time, use the resolve of the inner Promise.
1924
+ // This can happen because the ping gets invoked before the await gets resolved.
1925
+ if (ioNode.end < node.start) {
1926
+ // If we're awaiting a resolved Promise it could have finished before we started.
1927
+ node.end = node.start;
1928
+ } else {
1929
+ node.end = ioNode.end;
1930
+ }
1931
+ }
1932
+ if (node.end < cutOff) {
1933
+ // This was already resolved when we started this sequence. It must have been
1934
+ // part of a different component.
1935
+ // TODO: Think of some other way to exclude irrelevant data since if we awaited
1936
+ // a cached promise, we should still log this component as being dependent on that data.
1937
+ return null;
1938
+ }
1939
+
1940
const stack = filterStackTrace(
1941
request,
1942
parseStackTrace(node.stack, 1),
1951
// We log the environment at the time when the last promise pigned ping which may
1952
// be later than what the environment was when we actually started awaiting.
1953
const env = (0, request.environmentName)();
1954
+ if (node.start <= cutOff) {
1955
+ // If this was an await that started before this sequence but finished after,
1956
+ // then we clamp it to the start of this sequence. We don't need to emit a time
1957
+ // TODO: Typically we'll already have a previous time stamp with the cutOff time
1958
+ // so we shouldn't need to emit another one. But not always.
1959
+ emitTimingChunk(request, task.id, cutOff);
1960
+ } else {
1961
+ emitTimingChunk(request, task.id, node.start);
1962
+ }
1963
// Then emit a reference to us awaiting it in the current task.
1964
request.pendingChunks++;
1965
emitDebugChunk(request, task.id, {
1968
owner: node.owner,
1969
stack: stack,
1970
});
1971
+ emitTimingChunk(request, task.id, node.end);
1972
}
1973
}
1974
// If we had awaited anything we would have written it now.
2004
// We log the environment at the time when we ping which may be later than what the
2005
// environment was when we actually started awaiting.
2006
const env = (0, request.environmentName)();
2007
+ // If we don't have any thing awaited, the time we started awaiting was internal
2008
+ // when we yielded after rendering. The cutOff time is basically that.
2009
+ emitTimingChunk(request, task.id, cutOff);
2010
emitDebugChunk(request, task.id, {
2011
awaited: ((awaitedNode: any): ReactIOInfo), // This is deduped by this reference.
2012
env: env,
2013
});
2014
+ emitTimingChunk(request, task.id, awaitedNode.end);
2015
}
2016
}
2017