if (!/^[A-Fa-f0-9]{64}$/.test(hashHex)) throw new Error(`Invalid hash ${hashHex}`)
if (typeof threshold !== 'number') throw new TypeError(`Invalid threshold ${threshold}`)
- // Ensure WebGPU is initialized else restart calculation
+ // Ensure WebGPU is initialized before calculating, up to a max time frame
if (PowGpu.#device == null) {
+ if (performance.now() > 8000) {
+ throw new Error(`WebGPU device failed to load in time.`)
+ }
setTimeout(async () => { await this.#calculate(hashHex, callback, threshold) }, 100)
return
}