Razzle: Add error overlay like create-react-app's

Created on 1 Jun 2017  路  10Comments  路  Source: jaredpalmer/razzle

Create-react-app uses a custom webpack dev server client and its own custom error overlay. We could use switch to react-dev-utils/webpackHotDevClient.js, except that it uses window.location.port. From my initial explorations, this was the dealbreaker.

That being said, it would be really nice to get an error overlay like CRA's for Razzle

enhancement help wanted low

Most helpful comment

I am working with Dan to fix a bug that is preventing runtime errors from showing up. Right now only compiler / lint errors show

https://github.com/facebookincubator/create-react-app/pull/2515#issuecomment-325461989

All 10 comments

Hey @jaredpalmer!
What do you think of the idea to proxy all requests from /sockjs-node/ to the webpack server from the main entry point.
It's kind of hacky but probably a better solution than forking react-dev-utils/webpackHotDevClient.js and editing it to the webpack server port.
Preferably we'd have a middleware in razzle-dev-utils which could be used from src/index.js as so:

+import razzleHMRProxy from 'razzle-dev-utils/razzleHMRProxy';

export default express()
+   .use((req, res) => razzleHMRProxy(req, res))
    .use((req, res) => app.handle(req, res))
    .listen(port, function (err) {

Or furthermore, perhaps even ditch the webpack dev server entirely and migrate it to the webpack middleware? (swapping out the proxy in above example for a webpack middleware that razzle could export)

That would be cool.

What was the reasoning behind running the dev server on a seperate port in the first place instead of using the middleware, if I may ask?

@jaredpalmer 馃帀
Nice!

Does this display serverside errors too?

Don't think so. It works by creating a socket from webpack-dev-server and your client bundle.

I am working with Dan to fix a bug that is preventing runtime errors from showing up. Right now only compiler / lint errors show

https://github.com/facebookincubator/create-react-app/pull/2515#issuecomment-325461989

how about using componentDidCatch now that it exists? sorry if this has been discussed elsewhere before.

AFAIK componentDidCatch can鈥檛 be used with SSR

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ewolfe picture ewolfe  路  4Comments

jcblw picture jcblw  路  4Comments

piersolenski picture piersolenski  路  4Comments

dizzyn picture dizzyn  路  3Comments

GouthamKD picture GouthamKD  路  3Comments