diff --git a/engine/wasm.go b/engine/wasm.go index 32f98d9..4dedfcd 100644 --- a/engine/wasm.go +++ b/engine/wasm.go @@ -101,9 +101,9 @@ func (s *Server) LoadModule(cfg ModuleConfig) error { m.ctx, m.cancel = context.WithCancel(context.Background()) // Set Pool Size - m.poolSize = uint64(cfg.PoolSize) - if cfg.PoolSize == 0 { - m.poolSize = uint64(DefaultPoolSize) + m.poolSize = uint64(DefaultPoolSize) + if cfg.PoolSize > 0 { + m.poolSize = uint64(cfg.PoolSize) } // Read the WASM module file diff --git a/engine/wasm_test.go b/engine/wasm_test.go index e3902fa..779aa44 100644 --- a/engine/wasm_test.go +++ b/engine/wasm_test.go @@ -61,6 +61,17 @@ func TestWASMModuleCreation(t *testing.T) { }, }) + // Negative Pool Size + mc = append(mc, ModuleCase{ + Name: "Negative Pool Size", + Pass: true, + ModuleConf: ModuleConfig{ + Name: "A Module", + PoolSize: -1, + Filepath: "../testdata/hello-go/hello.wasm", + }, + }) + // No File mc = append(mc, ModuleCase{ Name: "No File",