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

React.Exceptions.ReactScriptLoadException shuts down debugging and IIS Express #189

Closed
SoonDead opened this issue Nov 10, 2015 · 9 comments
Labels

Comments

@SoonDead
Copy link
Contributor

Nowadays whenever I have a ReactScriptLoadException my debugging session shuts down.

I feed a webpack bundle to reactjs.net and whenever it changes (there is a separate webpack -w console that recompiles it) reactjs.net tries to reexecute it, throws an exception and that shuts down my iis express.

So basically everytime I hit ctrl+s on a jsx halfway through writing a function (where some variables are not declared yet for example) the debugging session shuts down. Since the project is large and needs around 30 seconds to start up, this is very annoying.

I'm asking for help on why this is happening and how to turn it off.

@Daniel15 Daniel15 added the Bug label Nov 11, 2015
@Daniel15
Copy link
Member

Wow, that's terrible :/ I haven't seen this yet myself, but I'll try to look into it on the weekend.

Try calling .SetReuseJavaScriptEngines(false) in your ReactConfig.cs and see if that helps. It will make page loads a bit slower, but it should be more reliable in this case.

@SoonDead
Copy link
Contributor Author

Yes it actually helps, thanks.

Also to try to nail down the exact issue:

Debugging only shuts down if the exception happens outside of a request (if it happens during (or more precisely as a result of) a request the error page is properly shown).

It is happening for both syntax errors and execution errors.

@Daniel15
Copy link
Member

I have a feeling this is happening because the exception is happening on a background thread. ReactJS.NET watches all files you load, and recycles the JavaScript engines if any of those files change. If any errors are encountered while loading the JS file, an exception is thrown. This approach is fine for initial load (as it's fine to throw exceptions on the request thread), but not for background stuff. I'll look into a better approach here.

@Daniel15
Copy link
Member

This should only be an issue with how scripts are loaded when you use AddScriptWithoutTransform. If you instead use AddScript, the error is handled correctly (as those scripts are loaded as part of the request, if they haven't already been loaded).

@SoonDead
Copy link
Contributor Author

Yes, I'm using AddScriptWithoutTransform because I already transform my scripts with webpack.

Daniel15 added a commit that referenced this issue Nov 16, 2015
…il GetEngine is called.

This ensures that errors are not thrown on a background thread if the engines are being initialised on a background thread (ie. when the engines are being recycled due to files being modified).

References #189
@Daniel15
Copy link
Member

@SoonDead - Can you please try out the latest dev build and see if it's any better? You can add https://ci.appveyor.com/nuget/reactjs.net as a NuGet package source to get the dev packages. Use version 2.0.2-dev-20151116-0644 or higher.

@SoonDead
Copy link
Contributor Author

I'll try it when I get to work (in about 1-2 hours).

@SoonDead
Copy link
Contributor Author

It seems to be working OK (it's not throwing exceptions when on a background thread).
Thanks you!

I have no idea if the javascript engine is properly reused or not, but the react component properly renders upon subsequent requests when the error is fixed.

@Daniel15
Copy link
Member

Thanks for the confirmation!

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

No branches or pull requests

2 participants