From the course: JavaScript: Web Workers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Handle worker errors

Handle worker errors - JavaScript Tutorial

From the course: JavaScript: Web Workers

Start my 1-month free trial

Handle worker errors

- [Instructor] What happens if some kind of error happens within the scope of the thread? So in the web worker. There is an error event that will be fired if there are unhandled exceptions in the thread. When combined to that error event within the worker itself or in the main thread. So the main thread can know if there is any error happening in one of its dedicated workers. Also, sometimes we can send wrong data on postMessage. In that case, another event will be fired. In this case the name means messageerror. Be careful with the double e that you have there. So it's messageerror in that case on both sides. You can know if there is a problem with the postMessage argument that you are sending. Why is that a problem? Because we have already seen that both message will accept all primitive types for Copy. So that's the default postMessage. Also you can send Date, RegularExpressions, Blob, File, Object, FileList, ArrayBuffers, ImageData, normal Arrays, normal Objects, Maps, and Sets…

Contents