[BUG] Worker fails to fallback to JavaScript solver when WASM is available but not fully supported
Describe the bug In certain older browsers (e.g., Chrome 86), WebAssembly is reported as supported but some WASM features may not be fully implemented. When the WASM solver fails in these environments, the system logs the message "[cap worker] using fallback solver due to error:", but does not actually fallback to the JavaScript solver, causing the CAPTCHA solving process to fail completely.
Affects:
- [] Standalone mode
- [x] Widget
- [] Server
- [] WASM
- [] Solver
- [] Solver CLI
To Reproduce Steps to reproduce the behavior:
- Use an older browser with partial WASM support (e.g., Chrome 86)
- Attempt to solve a CAPTCHA challenge
- Observe that WASM loading or execution fails
- Check console logs for "[cap worker] using fallback solver due to error:" message
- Note that the fallback JavaScript solver is not actually triggered
Expected behavior When WASM is available but fails during loading or execution, the worker should properly fallback to the JavaScript-based solver implementation.
Screenshots
Desktop (please complete the following information):
- OS: [win10]
- Browser [chrome]
- Version [86]
Additional context This issue affects users on older browsers that claim to support WASM but don't have complete implementation, potentially blocking them from completing CAPTCHA challenges entirely.
fixed by [email protected]
@tiagozip Still having issues with v0.1.26. I think the code logic shown below is problematic - it might not re-enter the if block
Same issue. @cap.js/widget: v0.1.30 @cap.js/server: v4.0.3
mind sharing a github repo or codesandbox reproducing the error so i can look into your specific case further?
mind sharing a github repo or codesandbox reproducing the error so i can look into your specific case further?
Here is a minimal example of using Cap.js with the Express framework: https://github.com/pxgo/capjs-demo To reproduce the issue, you can install Chrome 86.0.4240.111 in a system sandbox for testing. Recommended Chrome download link: https://github.com/dengcao/chrome/tree/main/windows/64Bit.
it seems to work perfectly fine, both with and without wasm enabled, on chrome and firefox.
@tiagozip Are you using the browser version mentioned in @pxgo comment? If WASM is completely disabled, there's no problem. However, some older browser versions support WASM but lack certain features, which causes the code execution to reach the following section.
self.onmessage = async ({ data: { salt, target, wasmUrl } }) => {
let fb;
if (wasmCacheUrl !== wasmUrl) {
wasmCacheUrl = wasmUrl;
await import(wasmUrl)
.then((wasmModule) => {
return wasmModule.default().then((instance) => {
solve_pow_function = (
instance?.exports ? instance.exports : wasmModule
).solve_pow;
});
})
.catch((e) => {
console.error("[cap worker] using fallback solver due to error:", e);
fb = true;
return solveFallback({ salt, target });
});
if (fb) return;
}
Please pay attention to the condition if (wasmCacheUrl !== wasmUrl). Depending on the challenge difficulty setting, this will be executed many times. It works normally for the first solveFallback, but on the second attempt, it will skip this if condition.
it seems to work perfectly fine, both with and without wasm enabled, on chrome and firefox.
![]()
What version of browser are you using? I can stably reproduce the issue in Chrome 86.0.4240.111.
ill look into it
