From 6d0344bbefbd7b1a1bd2c69f5557a3c6deb64de0 Mon Sep 17 00:00:00 2001 From: Miro Kuratczyk Date: Mon, 25 May 2026 18:25:28 -0400 Subject: [PATCH 1/3] feat: add sleep support --- pkg/workflows/wasm/host/execution.go | 5 +++++ pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go | 3 +++ pkg/workflows/wasm/host/module.go | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/pkg/workflows/wasm/host/execution.go b/pkg/workflows/wasm/host/execution.go index a12a6ceb33..bc4df12d7b 100644 --- a/pkg/workflows/wasm/host/execution.go +++ b/pkg/workflows/wasm/host/execution.go @@ -321,6 +321,11 @@ func (e *execution[T]) now(caller *wasmtime.Caller, resultTimestamp int32) int32 return ErrnoSuccess } +// TODO: comment +func (e *execution[T]) sleep(caller *wasmtime.Caller, ms int32) { + time.Sleep(time.Millisecond * time.Duration(ms)) +} + // Loosely based off the implementation here: // https://github.com/tetratelabs/wazero/blob/main/imports/wasi_snapshot_preview1/poll.go#L52 // For an overview of the spec, including the datatypes being referred to, see: diff --git a/pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go b/pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go index dfdad8114c..68bd020c1d 100644 --- a/pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go +++ b/pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go @@ -231,6 +231,9 @@ func SwitchModes(mode int32) //go:wasmimport env now func now(response unsafe.Pointer) int32 +//go:wasmimport env sleep +func sleep(ms int32) + //go:wasmimport env call_capability func callCapability(req unsafe.Pointer, reqLen int32) int64 diff --git a/pkg/workflows/wasm/host/module.go b/pkg/workflows/wasm/host/module.go index cce932515a..38ab844815 100644 --- a/pkg/workflows/wasm/host/module.go +++ b/pkg/workflows/wasm/host/module.go @@ -504,6 +504,13 @@ func linkNoDAG(m *module, store *wasmtime.Store, exec *execution[*sdkpb.Executio return nil, fmt.Errorf("error wrapping get_time func: %w", err) } + if err = linker.FuncWrap( + "env", + "sleep", + exec.sleep); err != nil { + return nil, fmt.Errorf("error wrapping sleep func: %w", err) + } + return linker.Instantiate(store, m.module) } From a5262c9e797cd34bd059c8e43a014f5cd7b48763 Mon Sep 17 00:00:00 2001 From: Miro Kuratczyk Date: Tue, 26 May 2026 13:07:03 -0400 Subject: [PATCH 2/3] Fix eventTypeClock --- pkg/workflows/wasm/host/wasip1.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/workflows/wasm/host/wasip1.go b/pkg/workflows/wasm/host/wasip1.go index b1d58b286d..6a7c48c5c9 100644 --- a/pkg/workflows/wasm/host/wasip1.go +++ b/pkg/workflows/wasm/host/wasip1.go @@ -122,7 +122,9 @@ func clockTimeGet(caller *wasmtime.Caller, id int32, precision int64, resultTime const ( subscriptionLen = 48 eventsLen = 32 +) +const ( eventTypeClock = iota eventTypeFDRead eventTypeFDWrite From 75645888d2b3588b957774c05f36495830a04675 Mon Sep 17 00:00:00 2001 From: Miro Kuratczyk Date: Tue, 26 May 2026 14:53:22 -0400 Subject: [PATCH 3/3] Revert "feat: add sleep support" This reverts commit e4a4d4f512ded094864b8f22700dd82a8ebc08ad. --- pkg/workflows/wasm/host/execution.go | 5 ----- pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go | 3 --- pkg/workflows/wasm/host/module.go | 7 ------- 3 files changed, 15 deletions(-) diff --git a/pkg/workflows/wasm/host/execution.go b/pkg/workflows/wasm/host/execution.go index bc4df12d7b..a12a6ceb33 100644 --- a/pkg/workflows/wasm/host/execution.go +++ b/pkg/workflows/wasm/host/execution.go @@ -321,11 +321,6 @@ func (e *execution[T]) now(caller *wasmtime.Caller, resultTimestamp int32) int32 return ErrnoSuccess } -// TODO: comment -func (e *execution[T]) sleep(caller *wasmtime.Caller, ms int32) { - time.Sleep(time.Millisecond * time.Duration(ms)) -} - // Loosely based off the implementation here: // https://github.com/tetratelabs/wazero/blob/main/imports/wasi_snapshot_preview1/poll.go#L52 // For an overview of the spec, including the datatypes being referred to, see: diff --git a/pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go b/pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go index 68bd020c1d..dfdad8114c 100644 --- a/pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go +++ b/pkg/workflows/wasm/host/internal/rawsdk/helpers_wasip1.go @@ -231,9 +231,6 @@ func SwitchModes(mode int32) //go:wasmimport env now func now(response unsafe.Pointer) int32 -//go:wasmimport env sleep -func sleep(ms int32) - //go:wasmimport env call_capability func callCapability(req unsafe.Pointer, reqLen int32) int64 diff --git a/pkg/workflows/wasm/host/module.go b/pkg/workflows/wasm/host/module.go index 38ab844815..cce932515a 100644 --- a/pkg/workflows/wasm/host/module.go +++ b/pkg/workflows/wasm/host/module.go @@ -504,13 +504,6 @@ func linkNoDAG(m *module, store *wasmtime.Store, exec *execution[*sdkpb.Executio return nil, fmt.Errorf("error wrapping get_time func: %w", err) } - if err = linker.FuncWrap( - "env", - "sleep", - exec.sleep); err != nil { - return nil, fmt.Errorf("error wrapping sleep func: %w", err) - } - return linker.Instantiate(store, m.module) }