go-starter-kit icon indicating copy to clipboard operation
go-starter-kit copied to clipboard

Errors during first request of development server

Open nanno77 opened this issue 7 years ago • 7 comments

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.

nanno77 avatar Mar 21 '17 17:03 nanno77

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

scarmuega avatar Mar 21 '17 18:03 scarmuega

@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.

nanno77 avatar Mar 22 '17 21:03 nanno77

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 avatar Apr 23 '17 20:04 ufukomer

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?

ufukomer avatar Apr 24 '17 13:04 ufukomer

@ufukomer, great!

Could you send a PR with updated deps?

olebedev avatar Apr 24 '17 13:04 olebedev

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.

iKonrad avatar Apr 24 '17 14:04 iKonrad

@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?

ufukomer avatar Apr 24 '17 15:04 ufukomer