Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError raised when prerendering. #269

Closed
adamcreekroad opened this issue Oct 15, 2019 · 0 comments
Closed

TypeError raised when prerendering. #269

adamcreekroad opened this issue Oct 15, 2019 · 0 comments

Comments

@adamcreekroad
Copy link
Contributor

I'll get a TypeError: Converting circular structure to JSON sometimes when prerendering. This has been hard to debug, because this error happens inside a prerendering context and is impossible to get a traceback. However, from what I've been able to find out this happens when loading the prerendering context in Opal.

Also to note, I've never been able to reproduce this in development, only on our staging server...

But here's the ruby traceback

File "<unknown>", line 0 in JavaScript at JSON.stringify (<anonymous>)
File "../mini_racer-0.2.4/lib/mini_racer.rb" line 179 in eval_unsafe
File "../mini_racer-0.2.4/lib/mini_racer.rb" line 179 in block (2 levels) in eval
File "../mini_racer-0.2.4/lib/mini_racer.rb" line 264 in timeout
File "../mini_racer-0.2.4/lib/mini_racer.rb" line 178 in block in eval
File "../mini_racer-0.2.4/lib/mini_racer.rb" line 176 in synchronize
File "../mini_racer-0.2.4/lib/mini_racer.rb" line 176 in eval
File "../config/initializers/mini_racer.rb", line 8 in eval
File "../hyperstack-5313d1173155/ruby/hyper-component/lib/hyperstack/component/isomorphic_helpers.rb" line 148 in send_to_opal
File "../hyperstack-5313d1173155/ruby/hyper-component/lib/hyperstack/component/isomorphic_helpers.rb" line 133 in load_opal_context
File "../hyperstack-5313d1173155/ruby/hyper-component/lib/hyperstack/component/isomorphic_helpers.rb" line 13 in load_context
File "../hyperstack-5313d1173155/ruby/hyper-component/lib/hyperstack/internal/component/rails/component_mount.rb" line 29 in block in context_initializer_options
File "../hyperstack-5313d1173155/ruby/hyper-component/lib/hyperstack/internal/component/rails/server_rendering/contextual_renderer.rb" line 30 in render

The JS being evaluated is

Opal.Hyperstack.$const_get('Component').$const_get('IsomorphicHelpers').$load_context("69892429083440-1570810425", "Components::Layout::Header")

That method (in Opal Ruby) returns either an instance of Context, or nil. I'm wondering if that is failing to convert to JSON (mini_racer converts whatever is returned to JSON) and breaking. I've monkey patched the method to always return true (since it doesn't like it anywhere relies on it returning a Context instance) and I haven't had that error since.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant