Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// This worker is designed to showcase worker error rate handling.
import WorkerClient from "iframe-coordinator/WorkerClient";
const client = new WorkerClient(() => {
// Shutdown requested from host. Clean-up; WorkerClient will ack
if (currTimeout) {
clearTimeout(currTimeout);
currTimeout = null;
}
});
let currTimeout = setTimeout(triggerError, getTimeout());
function triggerError() {
// Setup the next error call, since the error will stop this function execution
currTimeout = setTimeout(triggerError, getTimeout());
console.error('Triggering an intentional error from a worker. Will not pop rate limit');
foo.bar.baz();
}
import WorkerClient from "iframe-coordinator/WorkerClient";
const client = new WorkerClient(() => {
// Shutdown requested from host. Clean-up; WorkerClient will ack
if (currTimeout) {
clearTimeout(currTimeout);
currTimeout = null;
}
// Not strictly necessary, but a good practice
client.unsubscribe('host.topic');
});
// Routing example
// client.requestNavigation('/wikipedia');
// Pub-Sub Example
client.subscribe('host.topic');
client.onPubsub(publication => {