storj / uplink

Storj network Go library
MIT License
122 stars 17 forks source link

Undefined `net` functions #159

Closed hansy closed 10 months ago

hansy commented 10 months ago

Trying to use uplink with tinygo. When compiling, I run into these errors:

../../../../go/pkg/mod/github.com/jtolio/eventkit@v0.0.0-20221004135224-074cf276595b/client.go:200:20: undefined: net.ResolveUDPAddr
../../../../go/pkg/mod/github.com/jtolio/eventkit@v0.0.0-20221004135224-074cf276595b/client.go:205:19: undefined: net.DialUDP

Is this a tinygo issue?

mniewrzal commented 10 months ago

We never tried to use tinygo with uplink. Could you post full command you are trying? and maybe your go version?

egonelbre commented 10 months ago

Also, which tinygo version are you using?

hansy commented 10 months ago

For sure! Running this command:

tinygo build -o ./build/app.wasm -target wasm -no-debug ./...

Go version: 1.21.3 Tinygo: tinygo version 0.30.0 darwin/amd64

egonelbre commented 10 months ago

So, the issue is that you are targeting WASM, which does not have networking. Similarly, there are quite a lot of limitations on what WASM/JS stuff can do in a browser, which doesn't mesh that nicely with what uplink needs to do. e.g. it needs ~30 outgoing connections to download things. There are also limits on the security protocols that are allowed from browser.

So, unfortunately, at the moment, I don't think it's possible to run uplink from browser -- I would really love to, I mean really-really. We did some experiments a year or two ago, but that didn't go anywhere. There could be some new developments that would allow us to, but I'm not aware of them.

Also, I'm not quite sure whether tinygo already can do all the necessary reflection to support protobuf. We have some plans to fix it, but we still rely on it.

Though, we've implemented macaroon handling, such that it could be used from tinygo.

hansy commented 10 months ago

Ooo I wasn't aware of that. My bad. I appreciate you taking the time to explain it to me. Thank you so much for your help.