Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

time.Sleep does not work #67

@mathetake

Description

@mathetake

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions