olebedev / go-starter-kit

[abandoned] Golang isomorphic react/hot reloadable/redux/css-modules/SSR starter kit
Other
2.82k stars 359 forks source link

Errors during first request of development server #73

Open nanno77 opened 7 years ago

nanno77 commented 7 years ago

It looks like make serve starts everything up nicely but upon the first request the go server panics and throws a TypeError

panic: TypeError: Not a function: [object Object]

goroutine 9 [running]:
main.newJSVM.func1(0xc420014600)
    /Users/nanno/go/src/github.com/nanno77/houston/server/react.go:199 +0x4d1
github.com/nanno77/houston/vendor/github.com/dop251/goja_nodejs/eventloop.(*EventLoop).RunOnLoop.func1()
    /Users/nanno/go/src/github.com/nanno77/houston/vendor/github.com/dop251/goja_nodejs/eventloop/eventloop.go:109 +0x31
github.com/nanno77/houston/vendor/github.com/dop251/goja_nodejs/eventloop.(*EventLoop).run(0xc42018e340, 0xc42018e601)
    /Users/nanno/go/src/github.com/nanno77/houston/vendor/github.com/dop251/goja_nodejs/eventloop/eventloop.go:116 +0x77
created by github.com/nanno77/houston/vendor/github.com/dop251/goja_nodejs/eventloop.(*EventLoop).Start
    /Users/nanno/go/src/github.com/nanno77/houston/vendor/github.com/dop251/goja_nodejs/eventloop/eventloop.go:87 +0x44

I can't for the life of me figure out where this is going wrong. make install works without any errors, even make build works, but upon running the server the error is thrown.

I would love to play with this project a little bit. If someone has any thoughts please let me know.

scarmuega commented 7 years ago

I have the same exact behavior, I'll try to pull from a previous commit to see if symptoms change.

nanno77 commented 7 years ago

@scarmuega circling back on this one. I roughly figured out the problem as it pertains to me. Basically it was a JS error with Webpack not liking the syntax of require. Once I changed those to import in the sample app it all loaded up fine. It could be due to how I have babel configured globally, but I haven't had much time to dive into that.

ufukomer commented 7 years ago

I get the similar error when I update React from 14.0.0 to 15.0.0 and have no require in my code.

screen shot 2017-04-23 at 10 58 15 pm

Have an idea? (No changes on react.go)

ufukomer commented 7 years ago

Finally, I found the error. This is what happens when you update React and don't update Helmet. Goja does not show the error line in bundle.js which makes debugging process very hard. Isn't there an easier way for this?

olebedev commented 7 years ago

@ufukomer, great!

Could you send a PR with updated deps?

iKonrad commented 7 years ago

I was trying to update all the deps as well but it took me way too long and resigned.

Anyway, make sure to temporarily turn off server side rendering when you update dependencies, it'll make it easier to track down all the issues.

ufukomer commented 7 years ago

@iKonrad If you disable server rendering you won't get most of these errors. 😁

Let's turn this issue into print stack trace of goja errors. That is a goja issue lol. Check this out: https://github.com/dop251/goja/issues/28#issuecomment-293986147

Though it does not help much but better than none.

@olebedev I made lots of changes. I need to fork and update from scratch. So I can do it in the future, not today. By the way, I have not migrated to React Router v4. It is very complex to me for now. There are lots of changes in API. For example, no more onEnter method of a router. So we should fetch in the componentDidMount for client side. Therefore that requires changes on server code too, something like passing init values (store's initialState -> config values in our app) into template directly from Go instead of fetching it during the server render. Am I right?