Why window.onerror Reports Show 'Script error.' and How to Fix Them
A front-end observability guide explains why browser error dashboards often show a generic 'Script error.' with no file, stack, or line number. The root cause is a cross-origin restriction: browsers hide details of scripts loaded from another origin unless they are served with CORS headers and tagged accordingly. The article also notes that window.onerror misses resource load failures and unhandled promise rejections, which fire separate events. It walks through building a tested TypeScript error monitor that captures runtime errors, failed resources, and rejected promises. The author recommends rolling out CORS configuration before adding the crossorigin attribute, to avoid scripts failing to load entirely.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in