vugu-examples / tinygo

Vugu+Tinygo example
MIT License
13 stars 2 forks source link

stopped working #1

Open joe-getcouragenow opened 3 years ago

joe-getcouragenow commented 3 years ago

This repo worked for me a month ago, but now does not.

My environment works running no tinygo examples, just not using tinygo as the WASM compiler.


go run devserver.go

cd /Users/apple/workspace/go/src/github.com/vugu-examples/tinygo && go run devserver.go
2020/08/24 12:24:29 Starting HTTP Server at "127.0.0.1:8844"

I also tried just running it this way with tinygo turned off in the generate.go, but no luck. //go:generate vugugen -s

Wish it gave more info verbose to the screen about whats going on. Would make debugging easier.

bradleypeabody commented 3 years ago

Can you please elaborate more on what the problem is? When you browse to http://localhost:8844/ does it give an error on the page? Or in the browser console? Can you show the network requests involved (Network panel in Chrome), particularly any that are marked as error in red.

joe-getcouragenow commented 3 years ago

Hey @bradleypeabody

thanks for follow up.

The terminal only progresses as far as is shown in the Issue. It never progresses

On that page i just get the spinning waiting icon, and everything hangs, but zero errors: See screenshot with console:

Screenshot 2020-08-25 at 06 42 47

All the code is running off Master for everything. Everything is also in the proper GOPATH.. Really stumped on whats going on here.

Make file i am using if it helps:

# https://github.com/vugu/vugu
# https://github.com/vugu-examples/tinygo

# https://github.com/vugu/vgrun
VUGO_RUN_LIB=           github.com/vugu/vgrun
VUGO_RUN_FSPATH=        $(GOPATH)/src/$(VUGO_RUN_LIB)

VUGO_LIB=               github.com/vugu/vugu
VUGO_LIB_FSPATH=        $(GOPATH)/src/$(VUGO_LIB)
VUGO_LIB_VERSION=       v2.0.0

## Example tinygo
EX_TINYGO_LIB=          github.com/vugu-examples/tinygo
EX_TINYGO_FSPATH=       $(GOPATH)/src/$(EX_TINYGO_LIB)

## Example todo 
# https://github.com/vugu-examples/todo
EX_TODO_LIB=            github.com/vugu-examples/todo
EX_TODO_LIB_FSPATH=     $(GOPATH)/src/$(EX_TODO_LIB)

print:
    @echo
    @echo -- VUGO RUN --
    @echo VUGO_RUN_LIB:         $(VUGO_RUN_LIB)
    @echo VUGO_RUN_FSPATH:      $(VUGO_RUN_FSPATH)
    @echo

    @echo
    @echo -- VUGO --
    @echo VUGO_LIB:             $(VUGO_LIB)
    @echo VUGO_LIB_FSPATH:      $(VUGO_LIB_FSPATH)
    @echo VUGO_LIB_VERSION:     $(VUGO_LIB_VERSION)
    @echo

    @echo
    @echo -- VUGO EX TINYGO --
    @echo EX_TINYGO_LIB:        $(EX_TINYGO_LIB)
    @echo EX_TINYGO_FSPATH:     $(EX_TINYGO_FSPATH)
    @echo

    @echo
    @echo -- VUGO EX TODO --
    @echo EX_TODO_LIB:          $(EX_TODO_LIB)
    @echo EX_TODO_LIB_FSPATH:   $(EX_TODO_LIB_FSPATH)
    @echo

git-clone:
    git clone https://$(VUGO_RUN_LIB).git $(VUGO_RUN_FSPATH)
    cd $(VUGO_RUN_FSPATH) && git fetch --all --tags --prune

    git clone https://$(VUGO_LIB).git $(VUGO_LIB_FSPATH)
    cd $(VUGO_LIB_FSPATH) && git fetch --all --tags --prune
    #cd $(VUGO_LIB_FSPATH) && git checkout tags/$(VUGO_LIB_VERSION)

    git clone https://$(EX_TINYGO_LIB).git $(EX_TINYGO_FSPATH)
    cd $(EX_TINYGO_FSPATH) && git fetch --all --tags --prune

    git clone https://$(EX_TODO_LIB).git $(EX_TODO_LIB_FSPATH)
    cd $(EX_TODO_LIB_FSPATH) && git fetch --all --tags --prune

git-delete:
    rm -rf $(VUGO_RUN_FSPATH)
    rm -rf $(VUGO_LIB_FSPATH)
    rm -rf $(EX_TINYGO_FSPATH)
    rm -rf $(EX_TODO_LIB_FSPATH)

### LIB

dep-build:
    mkdir -p $(PWD)/bin
    cd $(VUGO_RUN_FSPATH) && go build -o $(PWD)/bin/vgrun
    # put onto GOBIN
    cp $(PWD)/bin/vgrun $(GOPATH)/bin/.
    which vgrun
    # This fails so i install hem manually below.
    #vgrun -install-tools

    cd $(VUGO_LIB_FSPATH)/cmd/vugugen && go build -o $(PWD)/bin/vugugen
    cd $(VUGO_LIB_FSPATH)/cmd/vugufmt && go build -o $(PWD)/bin/vugufmt

    # put onto GOBIN
    cp $(PWD)/bin/vugugen $(GOPATH)/bin/.
    cp $(PWD)/bin/vugufmt $(GOPATH)/bin/.
    which vugugen
    which vugufmt

dep-clean:
    rm -rf $(PWD)/bin

    rm -rf $(GOPATH)/bin/vugugen
    rm -rf $(GOPATH)/bin/vugufmt
    rm -rf $(GOPATH)/bin/vgrun

# EX LIB
ex-new-gen:
    mkdir -p test
    cd test && vgrun -new-from-example=simple .
ex-new-run:
    cd test && vgrun devserver.go
    # Note to force tinygo change the generate.go contents to "//go:generate vugugen -tinygo"
    # open: 127.0.0.1:8844
ex-new-delete:
    rm -rf test

ex-tinygo-run:
    #cd $(EX_TINYGO_FSPATH) && vgrun devserver.go
    cd $(EX_TINYGO_FSPATH) && go run devserver.go

ex-todo-run:
    # needs wire
    go get github.com/google/wire/cmd/wire
    cd $(EX_TODO_LIB_FSPATH) && go generate
    cd $(EX_TODO_LIB_FSPATH) && go generate
joe-getcouragenow commented 3 years ago

So, when i run go generate from the repo (/Users/apple/workspace/go/src/github.com/vugu-examples/tinygo), it works.

The generate.go has the "//go:generate vugugen -s -tinygo" in it.

It generates 2 files: main_wasm.go 0_components_vgen.go

When i run it using go run devserver.go, it does NOT generate any files, so it seems that this is where things are broken

Also from looking at the code, tinygo compiler should be being spun up with docker ? I ask because i dont see docker being spun up at all.

joe-getcouragenow commented 3 years ago

Looking at the code here:https://github.com/vugu/vugu/blob/master/devutil/tinygo-compiler.go, that is responsible for spinning up the docker tinygo etc.

This might abstract most of that finicky code for you: https://github.com/testcontainers/testcontainers-go

Just an Idea because docker does not behave the same on all OS's

bradleypeabody commented 3 years ago

Okay and thanks for that info. I think what we need to see more of is what happens inside that wasm_exec.js call. Can you open that in a new tab and see if it is returning any error? Also note that to download the Tinygo docker image and light all that up the first time can take quite a while. Notice that the request is still Pending - I suspect it might actually be working and doing the correct steps but taking many minutes to complete. Maybe try doing a docker pull vugu/tinygo-dev:latest first and let that complete and then test again. Also in your devserver.go try calling SetLogWriter(os.Stderr) on your TinygoCompiler instance, so you can get more output.