Skip to content

Web Editor can't capture and display errors for p5.js >= 1.0.0 #1546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
akshay-99 opened this issue Aug 12, 2020 · 3 comments · Fixed by #1565 or #1580
Closed
1 task done

Web Editor can't capture and display errors for p5.js >= 1.0.0 #1546

akshay-99 opened this issue Aug 12, 2020 · 3 comments · Fixed by #1565 or #1580
Labels
Good First Issue A beginner-friendly issue, great for first-time contributors Help Wanted Would love additional input or contributions! Priority:High Should be addressed soon but not critical

Comments

@akshay-99
Copy link
Member

Nature of issue?

  • Found a bug

Details about the bug:

  • Web browser and version: Chrome 83.0.4103.116
  • Operating System: Ubuntu 18.04
  • Steps to reproduce this bug:

For sketches running on p5 versions 0.10.2 and older , the editor is able to capture an error, highlight the line and display the error in the editor console perfectly.
image
It cannot do the same for sketches running on newer versions of p5 ( >= 1.0.0 ) as seen here:
https://editor.p5js.org/akshay.padte/sketches/2yX5Q5CeV

This is likely because the initialization code for p5 was changed a bit in processing/p5.js#4233 ( just before 1.0.0 ) and it now runs inside a promise. Which also means that errors now happen inside a promise and would now be caught by unhandledrejection listener instead of onerror.

Also, since p5 0.6.0, several components of the FES report the line number of the error in the message. However since the editor concatenates the user-code into srcdoc, the line number reported by the FES is something like about:srcdoc:56:3
image

I was wondering if it's possible to fix this somehow. Maybe this belongs in an issue of its own.

@welcome
Copy link

welcome bot commented Aug 12, 2020

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

@catarak
Copy link
Member

catarak commented Aug 17, 2020

Thanks for reporting! It seems like the code meant to catch JS errors isn't intercepting unhandled promise rejections. This code is located in consoleUtils.js. Apparently window.onerror doesn't catch unhandled promise rejections, and a solution is proposed here.

@catarak catarak added Good First Issue A beginner-friendly issue, great for first-time contributors Help Wanted Would love additional input or contributions! Priority:High Should be addressed soon but not critical type:bug labels Aug 17, 2020
@ridait
Copy link
Contributor

ridait commented Aug 20, 2020

Hello,
I can take a look at this one unless someone is already on it.

catarak added a commit that referenced this issue Aug 20, 2020
…tion

Fixes #1546 capture and display rejected promises
catarak added a commit that referenced this issue Aug 26, 2020
…promise-interception

Revert "Fixes #1546 capture and display rejected promises"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue A beginner-friendly issue, great for first-time contributors Help Wanted Would love additional input or contributions! Priority:High Should be addressed soon but not critical
Projects
None yet
3 participants