mattkrick / meatier

:hamburger: like meteor, but meatier :hamburger:
3.05k stars 173 forks source link

prerender.js error #112

Closed cometta closed 8 years ago

cometta commented 8 years ago

After npm run build. I ran npm run prod, i get below error when click "refresh" on browser on this page http://127.0.0.1:3000/signup , the page is showing up as blank (unable to connect)


 [Error] TypeError: Cannot read property 'pathname' of undefined
    at u (/Users/meatier/build/prerender.js:27:7211)
    at n.configureFinalMapState (/Users/meatier/build/prerender.js:50:11937)
    at n.computeStateProps (/Users/meatier/build/prerender.js:50:11726)
    at n.updateStatePropsIfNeeded (/Users/meatier/build/prerender.js:50:12702)
    at n.render (/Users/meatier/build/prerender.js:50:14765)
    at [object Object].y._renderValidatedComponentWithoutOwnerOrContext (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:13:15968)
    at [object Object].y._renderValidatedComponent (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:13:16057)
    at [object Object].y.mountComponentAsync (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:13:12223)
    at Object.a.mountComponentAsync (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:15:3733)
    at m.y.Mixin.renderChildren (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:14:27142)
    at m.y.Mixin.mountChildrenAsync (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:14:26959)
    at m.Mixin._createContentMarkupAsync (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:13:25084)
    at m.Mixin.mountComponentAsync (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:13:23226)
    at Object.a.mountComponentAsync (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:15:3733)
    at m.y.Mixin.renderChildren (/Users/meatier/node_modules/react-dom-stream/dist/react.min.js:14:27142)
    at /Users/meatier/node_modules/react-dom-stream/dist/react.min.js:14:27200

However, there is no error when i run npm run start

bartekus commented 8 years ago

Running npm run build will not execute npm run build:db... I'd suggest pulling fresh clone from git hub and executing: rethinkdb in one terminal and npm install && npm run quickstart in another one.

cometta commented 8 years ago

unfortunately, i retried and downloaded fresh meatier and still get similar error when refresh http://127.0.0.1:3000/signup page . Did you try to refresh the page?, no problem when running on dev mode (npm run start)

bartekus commented 8 years ago

Why not localhost? 127.0.0.1 is technically the same thing, except it isn't when you are dealing with graphQL and also when you have instance of hardcoded localhost in the code. I would try to use http://localhost:3000 instead as I'm sure that it will work.

cometta commented 8 years ago

I wished it work but it did not. I captured a screenshot for you

Image of screenshot

please note the page is able to display probably if i did not press refresh on browser

bartekus commented 8 years ago

Ok, are you running rethinkdb in another terminal? Because I see that that SocketCluster is creating a pool connected to port 32769, which unless you've changed something is most likely not correct. Normally I would expect something like this:

> NODE_ENV=production node ./src/server/server.babel.js

   [Busy] Launching SocketCluster
   >> Broker PID: 9114
Creating a pool connected to localhost:28015
   >> Worker PID: 9116
   [Active] SocketCluster started
            Version: 4.3.2
            Port: 3000
            Master PID: 9111
            Worker count: 1
            Broker count: 1

So by the looks of it GraphQL is having issue here. Do you use sudo to install global npm packages? If you do, then please refer to this article to alleviate this potential source of the issue: fixing-npm-permissions If not, what version of node node -v and npm npm -v are you using? Since you can run in the dev mode, can you also access http://localhost:3000/graphql when using it?

cometta commented 8 years ago

yes, i have global npm user:meatier $ npm --version 3.8.1 user:meatier $ node --version v5.8.0

my rethinkdb is running on another machine not localhost. as i did mention no issue when running npm run start . no issue viewing graphql gui as well. Only compiled codes having issue prerender.js

bartekus commented 8 years ago

Yeah to be honest with you the current prerender.js is a bit of magical workaround to get material ui working server side and given that we're switching to react-toolbox, it's one of the first we're be looking at.

mattkrick commented 8 years ago
  1. in the server webpack config, disable uglify
  2. rebuild & rerun
  3. go to the prerender.js and find the line & column that throws the error
  4. if you can't debug from there, paste the code that throws & we'll dig in from there
cometta commented 8 years ago

insider prerender.js

function mapStateToProps(state) {
  state = (0, _reduxOptimisticUi.ensureState)(state);
  var auth = state.get('auth');
  return {
    isAuthenticated: auth.get('isAuthenticated'),
    isAuthenticating: auth.get('isAuthenticating'),
    authError: auth.get('error').toJS(),
    pathname: state.get('routing').location.pathname  <---this line
  };
}

I have identified the part of the code that has issue AuthContainer.js

kurtaschliman commented 8 years ago

@cometta I'm running into the same issue here. I don't have anything constructive yet except that the state of the routing reducer is:

{ location: undefined }

I'll be continuing to debug today and will post any results here.

KrishnaPG commented 8 years ago

Encountering same error. With 'npm start' looks like it is working fine.

mattkrick commented 8 years ago

ahhh, yeah the version bump of the redux router made it async so you have to code defensively or grab it from react-router. i'll bump to the next version of react-router-redux & fix this at the same time