airbnb / hypernova-ruby

Ruby client for Hypernova.
https://github.com/airbnb/hypernova
MIT License
141 stars 55 forks source link

the render result is __hypernova_render_token[0]__? #15

Closed loatheb closed 7 years ago

loatheb commented 7 years ago

I'm not sure, but sometime when I open a site use SSR with hypernova-ruby and hypernova-react, the site shows a __hypernova_render_token[0]__

also, I notice the node hypernova server doesn't log things about the request? Is that means the request is timeout in hypernova-ruby?

Thanks

loatheb commented 7 years ago

The reason is when our site use the cache, ruby running the hypernova_batch_before and hypernova_batch_after but doesn't run the render_react_component among them. So that the token doesn't be replaced in hypernova_batch_after and absolutely not send the request to the hypernova server.

At last, we remove the memory cache in our code, after that, it works well.

jtamary commented 7 years ago

The problem is that the hypernova writes the result to response.body and the caches_action reads from response_body.

A hacky solution we found to this problem is rewriting response_body[0] in the page controller. response_body[0] = response.body

we don't like it. :\ but it should work.

Another solution is writing your own cache mechanism in a higher level where you have the whole body.

maloky commented 5 years ago

Hi.

I've been struggling with a similar issue. In my case i'm trying to get the returned html to be rendering in pdf format. But it only displays correctly if i add the parameter to show_as_html to true. what's the big diference of render the result as html instead of pdf? shoudn't the render to string return the same?