Skip to content

Fix browser script load error rejection - #6333

Open
rileyjshaw wants to merge 1 commit into
google-ai-edge:masterfrom
rileyjshaw:codex/fix-script-load-errors
Open

Fix browser script load error rejection#6333
rileyjshaw wants to merge 1 commit into
google-ai-edge:masterfrom
rileyjshaw:codex/fix-script-load-errors

Conversation

@rileyjshaw

Copy link
Copy Markdown

What changed

  • Reject browser script load failures with an Error instead of the raw DOM Event.
  • Include the failed script URL in the error message.
  • Preserve the original load event as error.cause.
  • Add focused regression coverage for the rejection shape.

Why

When a MediaPipe WASM loader script fails to load, the browser dispatches a plain Event. The current error listener passes that event directly to the Promise rejection. Callers therefore receive a non-Error value with no useful message or stack, which obscures both the failed asset and where the load originated.

The original callback also named the Promise rejection function revoke, making the intended behavior less clear.

Impact

This changes only the browser <script> loading failure path. Successful loads and worker importScripts() behavior are unchanged. Existing catch blocks continue to receive a rejection, now with a conventional Error value and richer diagnostic context.

The project targets the ES2021 type library, which predates ErrorOptions. The implementation therefore defines the standard cause property explicitly instead of using the newer two-argument Error constructor.

Checks

  • TypeScript 5.3.3 strict compile of the helper and test: passed
  • Jasmine regression test: passed (1 spec)
  • Buildifier check for mediapipe/web/graph_runner/BUILD: passed
  • git diff --check: passed
  • bazelisk test //mediapipe/web/graph_runner:run_script_helper_test: blocked during target analysis by the current upstream rules_java module resolving @rules_java~//tools/jdk without a BUILD file; no changed source was compiled before this failure

@google-cla

google-cla Bot commented Aug 11, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@rileyjshaw
rileyjshaw marked this pull request as ready for review August 11, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant