Git Product home page Git Product logo

Comments (5)

daniluk4000 avatar daniluk4000 commented on June 19, 2024

Basically, any thrown error inside defineRenderHandler leads to this.

from nuxt.

daniluk4000 avatar daniluk4000 commented on June 19, 2024

As I've struggled deep into the code, the problem is probably that we can't rerender our app if any error happened.

The only thing that could delay some component from rendering is onServerPrefetch, but we can't wait inside of it forever since we can't know if remaining app has been rendered or not.

Solution could be is to listen for @resolve hook for that, but this is currently impossible due to vuejs/core#8555 not merged.

Also solution could be to render app twice (don't use Nitro's error handler) and on second render pass all the payload and state to this second render, and that will also skip mounting any plugins twice there. But I don't know if it is possible to preserve context somehow for multiple renders.

UPD: probably possible to restore state using useSSRContext().

from nuxt.

danielroe avatar danielroe commented on June 19, 2024

Yes, that is the case (and intentional). To render an error page, we render the app a second time, but just the error page and not app.vue.

Plugins might do more things than set payload/state, such as inject helper functions. So we do need to rerun them. You can add your own logic to avoid rerunning logic. You can check in your plugins if useError().value is set.

from nuxt.

daniluk4000 avatar daniluk4000 commented on June 19, 2024

Yes, that is the case (and intentional). To render an error page, we render the app a second time, but just the error page and not app.vue.

Plugins might do more things than set payload/state, such as inject helper functions. So we do need to rerun them. You can add your own logic to avoid rerunning logic. You can check in your plugins if useError().value is set.

Yes I could, but sadly pinia context is lost as well :(

So I have to refetch for my data

from nuxt.

daniluk4000 avatar daniluk4000 commented on June 19, 2024

@danielroe do you think this worth trying to solve when @resolve on Suspense will be supported on SSR? Basically, that's how it worked in Nuxt 2 (I know that there was totally different logic).

If at least state (including useState & pinia) would be passed to this reloaded context, it wouldn't be such a problem.

from nuxt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.