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

Add error overlay like create-react-app's #284

Closed
jaredpalmer opened this issue Jun 1, 2017 · 10 comments
Closed

Add error overlay like create-react-app's #284

jaredpalmer opened this issue Jun 1, 2017 · 10 comments

Comments

@jaredpalmer
Copy link
Owner

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

@jariz
Copy link
Collaborator

jariz commented Jul 17, 2017

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) {

@jariz
Copy link
Collaborator

jariz commented Jul 17, 2017

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)

@jaredpalmer
Copy link
Owner Author

That would be cool.

@jariz
Copy link
Collaborator

jariz commented Jul 17, 2017

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?

@jariz
Copy link
Collaborator

jariz commented Aug 28, 2017

@jaredpalmer 🎉
Nice!

@jariz
Copy link
Collaborator

jariz commented Aug 28, 2017

Does this display serverside errors too?

@jaredpalmer
Copy link
Owner Author

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

@jaredpalmer
Copy link
Owner Author

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

facebook/create-react-app#2515 (comment)

@tsiq-swyx
Copy link

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

@jaredpalmer
Copy link
Owner Author

AFAIK componentDidCatch can’t be used with SSR

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

Successfully merging a pull request may close this issue.

3 participants