From 4e357d5dbec66d07ce45bb06810a33d7c8138e54 Mon Sep 17 00:00:00 2001 From: Alberto bebbo Capponi Date: Thu, 3 Oct 2024 15:01:38 +1000 Subject: [PATCH] Update rollbar.js Fix loop in vue 3 --- examples/vuejs3/src/rollbar.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/examples/vuejs3/src/rollbar.js b/examples/vuejs3/src/rollbar.js index 0887d9fd..08b25525 100644 --- a/examples/vuejs3/src/rollbar.js +++ b/examples/vuejs3/src/rollbar.js @@ -7,11 +7,23 @@ const rollbar = new Rollbar(config); export default { install(app) { app.config.errorHandler = (error, vm, info) => { - rollbar.error(error, { vueComponent: vm, info }); - if (app.config.devtools) { - console.error(error); - } - }; + + // In case the error is from the router or am helper + // calling vm could generate a loop and freeze the browser + // rollbar.error(error, { vueComponent: vm, info }); + + rollbar.error(error, { info }); + + if (app.config.devtools) console.error(error); + } + + + app.config.warningHandler = (error, vm, info) => { + rollbar.warning(error, { info }); + + if (app.config.devtools) console.log('just a warning, but!,error) + } + app.provide('rollbar', rollbar); }, };