-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
chore(webkit): working around WebKit bug by patching Error #23588
Conversation
Thanks for taking the time to open a PR!
|
let originalError = autWindow.Error | ||
|
||
autWindow.Error = function (...args) { | ||
autWindow.queueMicrotask(() => {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this now, I wondered if this could backfire and cause an infinitely expanding queue, but I can't think of a scenario where that would happen where the user wouldn't already be doing infinite recursion anyways. So this seems safe enough...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought of one - if window.queueMicrotask
is monkey-patched to throw an Error itself, this would infinitely recurse. But that seems unlikely to happen in the wild. Maybe we could name this function something like __CyWebKitError
so that it's at least identifiable in a stack trace in case someone does run in to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That does seem unlikely, but naming the function is a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could even try...catch
the queueMicrotask
call... but... then that could also lead to really hard-to-debug issues ("why does my queueMicrotask monkey-patch make unhandled rejections not get caught by Cypress???"), so I think the way you have it is good for now. Let's see if any bug reports roll in.
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
User facing changelog
N/A
Additional details
There were a few test cases within
uncaught_errors.cy.js
that were failing for the WebKit browser. The errors that were being thrown and uncaught within a Promise chain were not being received by Cypress. The root cause can be found documented within a WebKit bug report here; it shows a minimal reproduction, which I can confirm with my own findings.A good bit of debugging and trial and error resulted in the work-around in this PR. It was found that any sort of operation executed after the Error was thrown would ensure that the proper error handlers would fire. A no-op microtask was chosen for this purpose, as it seems to have the smallest chance of impacting other functionality.
Steps to test
With this PR, all uncaught_errors specs will pass without any modification across our supported browsers.
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?