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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Worker: reorganize components and refactor error handling #863
Conversation
}) | ||
|
||
// Reset pool | ||
this.workers.clear() |
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.
Note that this is not strictly necessary based on our usage (we create a new instance on initialization), but it does feel safer :)
'error', | ||
error => { | ||
console.error('Error from worker for ${name} (loaded from ${scriptUrl}):', error.message, error) | ||
window.parent.postMessage( |
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.
The big change here was to avoid passing the error through postMessage
. Errors can't be copied through the Structured Cloning algorithm
false | ||
) | ||
window.addEventListener('message', ({ data, source }) => { | ||
if (source === window.parent) { |
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.
This is also important; we need to check the source of the message, otherwise it could be another window sending information to this iframe.
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.
馃毧 馃毧 馃毧
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.
馃殌 馃帀
When testing the original iframe worker I tested only on my dev setup, only to realise later on that an error was happening with the built code - just fyi.
Tested it with the production build locally and nothing seems out of the ordinary :). |
Puts all of the WebWorker related components into
worker/
.removeWorker()
API (I think it's a bit more clear)