Skip to content

Stop throwing non-sketch errors as Skulpt exception - #1707

Open
cocomarine wants to merge 2 commits into
mainfrom
1924-fix-p5-fes-error-monitor-leak
Open

cocomarine wants to merge 2 commits into
mainfrom
1924-fix-p5-fes-error-monitor-leak

Conversation

@cocomarine

@cocomarine cocomarine commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1924

Added more details to the issue comment.

Problem

  • p5's friendly error system (fes) adds a listener to window for error and unhandledrejection events for the life of the page, so it sees all of them including any unrelated page errors.
  • With _friendlyError throwing, the listener rethrows unrelated page errors as Skulpt exceptions.
  • Why the old fix in Handle non-standard p5/py5 exceptions #1561 didn't work for this?
    • Handle non-standard p5/py5 exceptions #1561 handled errors raised inside preload/setup/draw, but this path never goes through the sketch, so it kept happening. It can also happen after the sketch has stopped, or in a non-p5 project once p5 has loaded.

Changes

  • Removed p5's global error monitor from window once _friendlyError is overridden.
    • Sketch errors already routed through Sk.uncaughtException, so we can remove this.

@cocomarine

Copy link
Copy Markdown
Contributor Author

@macroscope-app review

@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown

Manual reviews triggered for commit f2e58f8:

All prior checks · these links stay valid even if you push more commits.

@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown

Review started; results will be posted in the check runs.

@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown

Approvability

Verdict: Would Approve

Macroscope's review found this PR approvable — This focused fix removes p5's global friendly-error listeners after the shim takes ownership of sketch errors, preventing unrelated page errors from appearing as Python exceptions. The mirrored p5/py5 changes are small, directly tested for p5, and leave the existing sketch error-routing path intact.

Needs human approval because:

  • automatic approval is not enabled for this workspace

Notes:

  • Diff unchanged. Approvability was decided on eligibility alone.

Enable approvability here. You can add or adjust custom eligibility rules. Learn more.

This branch was successfully deployed

1 active deployment
previews/1707/merge — f2e58f88 Deployed Oct 22, 2026 by cocomarine via deploy-branch / build-deploy #6978
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