Skip to content

TypeError raised when prerendering. #269

Closed
@adamcreekroad

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions