Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Defer + single resolved promise causes "Deferred data aborted" error in dev tools #9706

Closed
jklosinski opened this issue Dec 8, 2022 · 9 comments · Fixed by #9965
Closed
Labels

Comments

@jklosinski
Copy link

What version of React Router are you using?

6.4.0

Steps to Reproduce

I modified the Deferred example app: https://stackblitz.com/edit/github-roj5bp?file=src/routes.tsx

  1. Open sample above
  2. Open dev tools
  3. Click on Deferred 2
  4. Click on Home
  5. In dev tools, you should get a "Deferred data aborted" error even though the object passed to defer contains only a single resolved promise

Is this behavior expected? I can't find any info about it on the web.

Expected Behavior

The object passed to defer has just one resolved value:

export async function deferredLoader2() {
  return defer({
    critical1: await resolve("Critical 1", 250),
  });
}

So I would expect that there should not be any errors around deferred data being aborted.

Actual Behavior

The error is thrown. One thing to note, is that if you click on the Deferred link (which is unmodified from the example app) and let it load, the error does not occur.

@jklosinski jklosinski added the bug label Dec 8, 2022
@mikiyasET
Copy link

mikiyasET commented Jan 3, 2023

I'm having same issue

Loader

export const DashboardLoader = async () => {
    return defer({
        users: await Service.Run().UserService.getAllUsers()
    });
}

calling it

const loaderData:any = useLoaderData();

 return (<Suspense fallback={<div>Loading...</div>}>
        <Await resolve={loaderData.users} errorElement={<div>Error</div>}>
            {(data) =>
                <p></p>
            }
        </Await>
    </Suspense>

and there is a error on the log
image

@seanmcquaid
Copy link

Seeing the same issue as well!

@brophdawg11
Copy link
Contributor

I'll look into detecting this, but this isn't really a valid use case for defer() since you're not actually deferring anything. defer() expects at least one Promise as a value in the object passed to defer. If everything is await'd then you can just use json().

@brophdawg11 brophdawg11 self-assigned this Jan 23, 2023
@seanmcquaid
Copy link

@brophdawg11 - What about cases where you'd want to conditionally await? For example, when you either want to grab data from a cache or fetch if there is nothing in the cache.

@brophdawg11
Copy link
Contributor

brophdawg11 commented Jan 23, 2023

That would be a valid use case, but it's not the use case described in this issue 😜. The linked PR will get rid of the console error 👍

@seanmcquaid
Copy link

Aw man, my bad! You're totally right. Appreciate the work you're doing!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 6.7.1-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 added the awaiting release This issue have been fixed and will be released soon label Jan 24, 2023
@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 6.8.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue have been fixed and will be released soon label Jan 26, 2023
@brophdawg11 brophdawg11 removed their assignment Jan 26, 2023
@mikiyasET
Copy link

mikiyasET commented Jan 28, 2023

I'm having same issue

Loader

export const DashboardLoader = async () => {
    return defer({
        users: await Service.Run().UserService.getAllUsers()
    });
}

calling it

const loaderData:any = useLoaderData();

 return (<Suspense fallback={<div>Loading...</div>}>
        <Await resolve={loaderData.users} errorElement={<div>Error</div>}>
            {(data) =>
                <p></p>
            }
        </Await>
    </Suspense>

and there is a error on the log image

This is fixed with the new update, Thanks and we all appreciate the work you guys are doing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants