Silent Errors in JS

Problem description:
Some errors don’t show up in the javascript console

Expected behavior:
Errors should show up

Actual behavior:
Errors don’t show up
ex:

Steps to reproduce:
There are a ton of ways to get silent errors,

Bug appears at this link:
https://replit.com/@HydrogenMacro/Error-demo?v=1#front/main.js
If anyone does fork this, then go to front/main.js and uncomment the import to get the error. It should not show anything in the webview, and there shouldn’t be anything in both consoles

Browser/OS/Device:
Mobile iOS Safari (probably part of the issue)

turns out the error was due to a misspelling of a variable, kinda annoying to find if there aren’t any errors

try-catch does work, but it is still pretty annoying to not have native errors

1 Like

Put

"use strict"

At the start of your JS file, to prevent variables from being implicitly defined on assignment instead of raising an error – the only way I can think that a misspelled variable can cause a silent error

The script type is module, so there should already be strict mode

so it wasn’t precisely a variable misspelling, but having a . before an import that wasn’t meant to be relative. This causes a 404 error, which the browser points at the file you tried to import and not the JS file.

hmm interesting, though the file path is correct
It probably does have something to do with 404s, since when I fixed an mistype of a file name in the exporting file (it parses images), everything worked