Giter VIP home page Giter VIP logo

Comments (3)

braska avatar braska commented on June 12, 2024 2

Yes, I understood the purpose of ssrPromises array, but...

Let's say:

  1. I deployed application that uses axios-hooks (for example on AWS).
  2. I am trying to open my application from my laptop and from smartphone on the same time. So, there are two requests for server.
  3. Server receiving first request and starting to push promises to ssrPromises.
  4. While server processes the first request (not all promises resolved or even React.renderToString is still executing), another request is received (it is possible because Node.js is async by the nature and uses non-blocking I/O model) and promises related to second request will be pushed to ssrPromises.
  5. When await serializeCache() will be called for the first request, it will be in pending state until all promises (including promises related to second request) will be resolved.
  6. In this const cache = ... for the first request will contains some data related to second request.

This is a pretty common issue across React ecosystem. So there is known solution.

For example, https://github.com/nfl/react-helmet suffer from this kind of problem too. I am very surprised that react-helmet didn't resolved this problem for all years of existing. But there is existing fork that solves problem: https://github.com/staylor/react-helmet-async.

I am trying to say that this lib (axios-hooks) needs something like what react-helmet-async do to isolate request contexts.

from axios-hooks.

simoneb avatar simoneb commented on June 12, 2024 1

Oh wow, you have a very good point indeed. I'll think of something, haven't done something like this before but I'm sure there must be a reasonably easy solution. Thanks for reporting!

from axios-hooks.

simoneb avatar simoneb commented on June 12, 2024

That's the purpose exactly, if I understand what you mean. This is for SSR, where we need to wait for alla requests to complete before rendering the application on the server.

from axios-hooks.

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.