diff --git a/wasm_parts/main.go b/wasm_parts/main.go index cfed83c4..0a62032e 100644 --- a/wasm_parts/main.go +++ b/wasm_parts/main.go @@ -112,7 +112,7 @@ var eng *promql.Engine = nil var engC = 0 func getEng() *promql.Engine { - if eng == nil || engC >= 5 { + if eng == nil || engC > 5 { eng = promql.NewEngine(promql.EngineOpts{ Logger: TestLogger{}, MaxSamples: 100000, diff --git a/wasm_parts/main.js b/wasm_parts/main.js index ec61a2fa..75b789fb 100644 --- a/wasm_parts/main.js +++ b/wasm_parts/main.js @@ -8,28 +8,31 @@ class WasmError extends Error {} module.exports.WasmError = WasmError let counter = 0 -var go = new Go(); const getWasm = (() => { - let wasm = null; - let cnt = 0; - let run = false; + const _Go = Go + var go = new _Go(); + let wasm = null + let cnt = 0 + let run = false async function init () { - run = true; + go = new _Go(); + run = true const _wasm = await WebAssembly.instantiate( - gunzipSync(fs.readFileSync(WASM_URL)), go.importObject) + gunzipSync(fs.readFileSync(WASM_URL)), go.importObject) go.run(_wasm.instance) wasm = _wasm.instance cnt = 0 - run = false; + run = false } - init(); + init() return () => { - if (cnt > 5 && !run){ - init(); - } - return wasm + if (cnt >= 20 && !run) { + init() } + cnt++ + return wasm + } })() const newId = () => { diff --git a/wasm_parts/main.wasm.gz b/wasm_parts/main.wasm.gz index 8a67265e..cf02a026 100644 Binary files a/wasm_parts/main.wasm.gz and b/wasm_parts/main.wasm.gz differ