Skip to content

How are server rendering JS errors handled? #386

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

Closed
justin808 opened this issue Oct 29, 2015 · 2 comments
Closed

How are server rendering JS errors handled? #386

justin808 opened this issue Oct 29, 2015 · 2 comments

Comments

@justin808
Copy link
Collaborator

I'm wondering if react-rails throws or simply logs when there's a server rendering error (JavaScript exception).

We're trying to decide on the functionality for react_on_rails: shakacode/react_on_rails#69

If we have an error when server rendering, should we:

  1. Log the messages to the client and/or server console.
  2. Throw an error on the server side so rails sees the error.
  3. Make the choice of 1) or 2) configurable? with the default being?
    config.throw_on_server_render_error = true
@rmosolgo
Copy link
Member

Hi @justin808,

We catch errors as they leave ExecJS, then re-raise them: https://github.com/reactjs/react-rails/blob/master/lib/react/server_rendering/exec_js_renderer.rb#L24

Feel free to try this out yourself by downloading the gem and taking it for a spin!

@justin808
Copy link
Collaborator Author

Thanks @rmosolgo! I should make a quick test and compare what happens.

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

2 participants