Skip to content

Commit 60d0c72

Browse files
committed
CRE-1320
1 parent bd03513 commit 60d0c72

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkg/workflows/wasm/host/module.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,24 @@ type linkFn[T any] func(m *module, store *wasmtime.Store, exec *execution[T]) (*
139139
// WithDeterminism sets the Determinism field to a deterministic seed from a known time.
140140
//
141141
// "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
142-
func WithDeterminism() func(*ModuleConfig) {
143-
return func(cfg *ModuleConfig) {
142+
func WithDeterminism() func(*ModuleConfig) error {
143+
return func(cfg *ModuleConfig) error {
144144
t, err := time.Parse(time.RFC3339Nano, "2009-01-03T00:00:00Z")
145145
if err != nil {
146-
panic(err)
146+
return fmt.Errorf("failed to parse determinism time: %w", err)
147147
}
148148

149149
cfg.Determinism = &DeterminismConfig{Seed: t.Unix()}
150+
return nil
150151
}
151152
}
152153

153-
func NewModule(ctx context.Context, modCfg *ModuleConfig, binary []byte, opts ...func(*ModuleConfig)) (*module, error) {
154+
func NewModule(ctx context.Context, modCfg *ModuleConfig, binary []byte, opts ...func(*ModuleConfig) error) (*module, error) {
154155
// Apply options to the module config.
155156
for _, opt := range opts {
156-
opt(modCfg)
157+
if err := opt(modCfg); err != nil {
158+
return nil, err
159+
}
157160
}
158161

159162
if modCfg.Logger == nil {

0 commit comments

Comments
 (0)