Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time.Sleep does not work #67

Closed
mathetake opened this issue Oct 1, 2020 · 3 comments
Closed

time.Sleep does not work #67

mathetake opened this issue Oct 1, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@mathetake
Copy link
Member

mathetake commented Oct 1, 2020

With the following code:

// override
func (ctx faultInjection) OnHttpRequestHeaders(int, bool) types.Action {
	if time.Now().UnixNano()%100 < 5 {
		time.Sleep(time.Millisecond * 500)
		proxywasm.LogInfo("sleep for 500 milliseconds...")
	}
	return types.ActionContinue
}

we have the following compile error

tinygo build -o ./examples/fault_injection/main.go.wasm -target=wasi -wasm-abi=generic ./examples/fault_injection/main.go
panic: trying to make exported function async: proxy_on_request_headers

goroutine 1 [running]:
github.com/tinygo-org/tinygo/transform.(*coroutineLoweringPass).findAsyncFuncs(0xc003e7b040)
        /home/circleci/project/transform/coroutines.go:186 +0xa64
github.com/tinygo-org/tinygo/transform.(*coroutineLoweringPass).load(0xc003e7b040, 0x20, 0x7f79bca925f0)
        /home/circleci/project/transform/coroutines.go:305 +0x36c
github.com/tinygo-org/tinygo/transform.LowerCoroutines(0x838d8b0, 0x838d801, 0x0, 0x0)
        /home/circleci/project/transform/coroutines.go:70 +0x15f
github.com/tinygo-org/tinygo/transform.Optimize(0x838d8b0, 0xc000267dd0, 0x2, 0x2, 0x5, 0x0, 0x0, 0x0)
        /home/circleci/project/transform/optimizer.go:120 +0xef0
github.com/tinygo-org/tinygo/builder.Build(0x7ffe3611dae1, 0x22, 0x7ffe3611da9a, 0x27, 0xc000267dd0, 0xc003e7bba8, 0x0, 0x0)
        /home/circleci/project/builder/build.go:109 +0x337a
main.Build(0x7ffe3611dae1, 0x22, 0x7ffe3611da9a, 0x27, 0xc0002a8000, 0x0, 0x12)
        /home/circleci/project/main.go:99 +0xc5
main.main()
        /home/circleci/project/main.go:909 +0x2071
make: *** [Makefile:10: build.example] Error 2

This seems something to do with scheduler

@mathetake
Copy link
Member Author

Or maybe unresolvable with the current TinyGo

@mathetake mathetake added bug Something isn't working help wanted Extra attention is needed labels Oct 1, 2020
@mathetake mathetake changed the title time.Sleep does not work in exported function time.Sleep does not work Oct 1, 2020
@mathetake
Copy link
Member Author

mathetake commented Oct 1, 2020

With -scheduler=none compiler option, we can compile the above code but get the other error:

Failed to load Wasm module due to a missing import: wasi_unstable.clock_time_get
Failed to load Wasm module due to a missing import: wasi_unstable.poll_oneoff

seems like V8 does not expose these WASI functions

@mathetake mathetake added enhancement New feature or request and removed help wanted Extra attention is needed bug Something isn't working labels Oct 2, 2020
@mathetake
Copy link
Member Author

mathetake commented Oct 21, 2020

there's nothing we can do in SDK so I'm closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant