Skip to content
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

Merged
merged 6 commits into from Jul 10, 2019

Conversation

sohkai
Copy link
Contributor

@sohkai sohkai commented Jul 8, 2019

Puts all of the WebWorker related components into worker/.

  • a8549e3: Just reorganizes the files
  • 9303050: Use an options object for the removeWorker() API (I think it's a bit more clear)
  • 13dc449: Reset the subscription pool when cancelling the aragon.js instance
  • e001f11: Refactor and improve error handling
  • fb51dd6: Some more comments 馃槃

@sohkai sohkai requested review from bpierre and AquiGorka July 8, 2019 15:31
})

// Reset pool
this.workers.clear()
Copy link
Contributor Author

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(
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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.

Copy link
Contributor

@bpierre bpierre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃毧 馃毧 馃毧

src/worker/WorkerSubscriptionPool.js Outdated Show resolved Hide resolved
Copy link
Contributor

@AquiGorka AquiGorka left a 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.

@sohkai
Copy link
Contributor Author

sohkai commented Jul 10, 2019

Tested it with the production build locally and nothing seems out of the ordinary :).

@sohkai sohkai merged commit d714d11 into master Jul 10, 2019
@sohkai sohkai deleted the worker-reorganize branch July 10, 2019 16:04
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.

None yet

3 participants