From 6f26adc8161bf0bac2a3d8221be243db72b0765f Mon Sep 17 00:00:00 2001 From: Samuel Holt Date: Tue, 6 Jul 2021 17:18:42 +1200 Subject: [PATCH 1/3] Wrap the navigator.sendBeacon call in a try catch to suppress any Illegal invocation errors, log the error if debugMode is enabled --- src/raygun.rum/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/raygun.rum/index.js b/src/raygun.rum/index.js index 37517690..ec200ac5 100644 --- a/src/raygun.rum/index.js +++ b/src/raygun.rum/index.js @@ -911,15 +911,22 @@ var raygunRumFactory = function(window, $, Raygun) { var stringifiedPayload = JSON.stringify(payload); - /** + /** * Use the navigator.sendBeacon method instead of a XHR requests when transmitting data - * This occurs mostly when the document is about to be discarded or hidden as + * This occurs mostly when the document is about to be discarded or hidden as * all inflight XHR requests either will be or can be canceled. - */ + */ if (self.sendUsingNavigatorBeacon && navigator.sendBeacon) { - navigator.sendBeacon(url, stringifiedPayload); + try { + navigator.sendBeacon(url, stringifiedPayload); + } catch (e) { + log(e, { + url: url, + payload: stringifiedPayload + }); + } return; - } + } makePostCorsRequest(url, stringifiedPayload, successCallback, errorCallback); } From 893b23ef541fa7a6cdf4f6b7453f845fffe327b0 Mon Sep 17 00:00:00 2001 From: Krishna Kapadia Date: Mon, 16 Aug 2021 09:53:48 +1200 Subject: [PATCH 2/3] Release: changelog updated + version bump. --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f1526b4..407321b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* v2.22.5 +- Fixes an issue where `navigator.sendBeacon` errors were not being handled gracefully. + * v2.22.4 - Upgrade the web-vitals vendor library to v2.1.0. - Fixes an issue where Core Web Vital timings were being queued behind virtual page timings. diff --git a/package.json b/package.json index 42639a89..ec5aa7b9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ ], "title": "Raygun4js", "description": "Raygun.com plugin for JavaScript", - "version": "2.22.4", + "version": "2.22.5", "homepage": "https://github.com/MindscapeHQ/raygun4js", "author": { "name": "MindscapeHQ", From c8680fc5a2478b9e81a14cca4a8f64684b813269 Mon Sep 17 00:00:00 2001 From: Krishna Kapadia Date: Mon, 16 Aug 2021 10:08:35 +1200 Subject: [PATCH 3/3] Release: version bump --- bower.json | 2 +- raygun4js.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 07b47588..77ea6242 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "raygun4js", - "version": "2.22.4", + "version": "2.22.5", "homepage": "http://raygun.io", "authors": [ "Mindscape " diff --git a/raygun4js.nuspec b/raygun4js.nuspec index cb3b027d..be300914 100644 --- a/raygun4js.nuspec +++ b/raygun4js.nuspec @@ -2,7 +2,7 @@ raygun4js - 2.22.4 + 2.22.5 Raygun4js Mindscape Limited Mindscape Limited