Is the `rewind` approach safe?
See original GitHub issueI’m wondering how the rewind
feature works internally. As far as I understand it simply outputs and removes the last rendered data that can be rendered on the server into a head. So is there something like a queue inside that the head data is being pushed on?
This assumes that the node.js server calls rewind
as soon as possible after the render, right? Couldn’t it happen that a new request comes in after a render that kicks off a new render and the rewind for the first request returns the data for the second request?
I might be totally wrong though – thanks in advance for the explanation! Very useful library btw.!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:33 (1 by maintainers)
Top Results From Across the Web
Rewind Technique - Psychology Tools
Clients should be cautious if their therapist is only proficient in the rewind technique and does not have trauma-specific CBT or EMDR training....
Read more >Advantages and Disadvantages of the “Rewind Technique”
Proponents of the “Rewind Technique” tout it as a safe and “startlingly effective” method that reduces post-traumatic symptoms in over 70% ...
Read more >The rewind technique - fast phobia and trauma treatment
The great thing about this technique is that it is completely safe and does not come with the risks of re-traumatising the client,...
Read more >How Rewind Therapy can help people with PTSD
When you undergo Rewind therapy, the trained therapist will help you to become totally relaxed and immersed in a 'safe space'. This involves...
Read more >The Rewind Technique And Why It Works - Step By Step
The Rewind Technique is an approach to working with trauma, especially individual traumas such as a road traffic accident. Clients who suffered anxiety, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the fast reply!
I did a bit more research and I found some related issues (seems like my concern is related to the underlying API of
react-side-effect
):The important takeaway for me is that there should only be synchronous logic between
renderToString
and the call torewind()
, as async logic will introduce the race condition.There are however also data fetching libraries that are rendering continuously in order to recursively fetch data for all components in the tree that need data (e.g. react-apollo does it – which is what I’m using – and also react-resolver I think). As far as I understand the node.js event loop, for these scenarios the data in
Helmet
can be inconsistent as the renders that are part of the data fetching can run in parallel – or rather parts of them after each other. Thus it’s important that there’s a finalrenderToString
call after all the data fetching so the data forreact-helmet
will get into a correct state and can be pulled out.I explained my findings in a bit more detail as maybe they could be helpful to someone else who is wondering about the same problem 😉.
I forked this repository and create react-safety-helmet to resolve this problem.
Everyone can simply migrate codes.
Also, React 16 renderToNodeStream is supported.
If possible, I will create a PR to react-helmet, but it will break the compatibility.