Unverified Commit d2bbca98 authored by Sebastian Markbåge's avatar Sebastian Markbåge Committed by GitHub

Make params and searchParams new Promises (#85158)

The problem is that without a new Promise, when all the awaits are in
third party, we'd keep searching down to the inner most which shows
`internal params`. We could maybe make the real value of those include
all params. But we can also just not dedupe to show the real value.
parent 40f48ebb
...@@ -456,15 +456,17 @@ function makeDynamicallyTrackedParamsWithDevWarnings( ...@@ -456,15 +456,17 @@ function makeDynamicallyTrackedParamsWithDevWarnings(
requestStore: RequestStore requestStore: RequestStore
): Promise<Params> { ): Promise<Params> {
if (requestStore.asyncApiPromises && hasFallbackParams) { if (requestStore.asyncApiPromises && hasFallbackParams) {
// Deliberately don't wrap each instance of params in a `new Promise()`. // We wrap each instance of params in a `new Promise()`, because deduping
// We want React Devtools to consider all the separate `params` promises // them across requests doesn't work anyway and this let us show each
// that we create for each segment to be triggered by one IO operation -- // await a different set of values. This is important when all awaits
// the resolving of the underlying `sharedParamsParent` promise. // are in third party which would otherwise track all the way to the
// It's created above any userspace code and has a `displayName`, // internal params.
// so it should show up in "suspended by". const sharedParamsParent = requestStore.asyncApiPromises.sharedParamsParent
const promise = requestStore.asyncApiPromises.sharedParamsParent.then( const promise: Promise<Params> = new Promise((resolve, reject) => {
() => underlyingParams sharedParamsParent.then(() => resolve(underlyingParams), reject)
) })
// @ts-expect-error
promise.displayName = 'params'
return instrumentParamsPromiseWithDevWarnings( return instrumentParamsPromiseWithDevWarnings(
underlyingParams, underlyingParams,
promise, promise,
......
...@@ -423,15 +423,16 @@ function makeUntrackedSearchParamsWithDevWarningsImpl( ...@@ -423,15 +423,16 @@ function makeUntrackedSearchParamsWithDevWarningsImpl(
let promise: Promise<SearchParams> let promise: Promise<SearchParams>
if (requestStore.asyncApiPromises) { if (requestStore.asyncApiPromises) {
// Deliberately don't wrap each instance of params in a `new Promise()`. // We wrap each instance of searchParams in a `new Promise()`.
// We want React Devtools to consider all the separate `searchParams` promises // This is important when all awaits are in third party which would otherwise
// that we create for each segment to be triggered by one IO operation -- // track all the way to the internal params.
// the resolving of the underlying `sharedParamsParent` promise. const sharedSearchParamsParent =
// It's created above any userspace code and has a `displayName`, requestStore.asyncApiPromises.sharedSearchParamsParent
// so it should show up in "suspended by". promise = new Promise((resolve, reject) => {
promise = requestStore.asyncApiPromises.sharedSearchParamsParent.then( sharedSearchParamsParent.then(() => resolve(proxiedUnderlying), reject)
() => proxiedUnderlying })
) // @ts-expect-error
promise.displayName = 'searchParams'
} else { } else {
promise = makeDevtoolsIOAwarePromise( promise = makeDevtoolsIOAwarePromise(
proxiedUnderlying, proxiedUnderlying,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment