gabrielbull / react-router-server

Server Side Rendering library for React Router v4.
MIT License
434 stars 17 forks source link

callstack exceeded results in server crash #19

Closed tswaters closed 7 years ago

tswaters commented 7 years ago

This might be the result of doing stupid things and using react-router in unexpected ways, but I found a mysterious crash that wound up being max callstack exceeded. You can see this if you take the react-router-server-complex-example project and make the following changes:

If you visit one route, it works fine... but visit another and hit refresh you'll get a server crash.

On my machine, Windows10 there is no actual error returned from the process.... but you can inspect %ERRORLEVEL% to see what the exit code is... here is the output from the shell,

D:\Code\react-router-server-complex-example>node_modules\.bin\babel-node.cmd --plugins system-import-transformer -- src/server.js
Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.
Example site listening on 3000!

^--- server crashes :(

D:\Code\react-router-server-complex-example>echo %ERRORLEVEL%
-1073741571

-1073741571 is a stack overflow exception.

I put a debugger on it in my own project where I found this initially, and I found that context.callback kept getting called, and went into another renderPass which ended up calling context.callback again.

I noticed the then callback in load was never fired, so add never gets called and the exists check never passes and the modules array kept getting the same module added over & over again.

gabrielbull commented 7 years ago

Can you try with release 4.2.0, I believe this is fixed.

tswaters commented 7 years ago

Hi, this works properly now, thanks!