Closed neuneed closed 1 year ago
Hi, There is two possibilities:
Based on what you explain, it seems like you are requesting the same page in getServerSideProps
and you are getting to a infinite loop. It is not required to make a request to Django within this function.
Since WSGI mode was ok and ASGI mode was not, you may have an sync custom middleware that causes this problem. It will produce a deadlock because of this sequence:
getServerSideProps
to get data.I think the secound one is more likely.
- Django is blocked
let me try this
If you're using django channels, make sure all your middlewares are async-capable.
Thank you!
@danialkeimasi After spending some time converting all my middlewares to use @sync_and_async_middleware
to support django middleware asynchronous, I managed to solve the issue!
Cheers!
Hello, I've encountered an issue when trying to integrate django-nextjs into my Django project. The issue arises when using ASGI and channels to run the server.
I have a URL path like so:
url(r'^content', views.nextjs_content, name='content')
, and the associated view function is an asynchronous function:Everything works perfectly fine in this setup, including Fast Refresh. However, when I introduce Server-Side Rendering (SSR) into my Next.js page (src/pages/content/[id].tsx), I start to encounter timeout errors. Specifically, my getServerSideProps function times out:
The error I get is: AxiosError: timeout of 20000ms exceeded.
Interestingly, if I switch back to WSGI mode using python manage.py runserver --noasgi and add
path("", include("django_nextjs.urls"))
to my URLs, everything works fine. However, in this setup, I lose the benefit of Fast Refresh.Could you provide some guidance on this? It seems like there might be some issue with the interaction between ASGI, Django-Nextjs, and Next.js's SSR.
Thank you for your time!