Repository navigation
Promise in transport appears to invoke twice #2506
Description
Activity
- changed the title
[-]Promise in Transport appears to invoke twice[/-][+]Promise in transport appears to invoke twice[/+]on Mar 19, 2020 Are you using
developmentenvironment of React? If so, it triggers errors twice in that mode. Please seeNote: https://docs.sentry.io/platforms/javascript/react/#error-boundarieschristopher-taormina-zocdoc commented
on Mar 19, 2020 AuthorMore actions@kamilogorek My component isn't extending from an ErrorBoundary currently. Additionally, it doesn't look like the
sendEventmethod is being called twice, just the code that I've defined in thatpromise.then. I've even hooked up to a test project and only see one event logged.christopher-taormina-zocdoc commented
on Mar 20, 2020 AuthorMore actions@kamilogorek I have an example I've tested in chrome that seems to duplicate this issue. I've been able to pin this down seemingly to being introduced in version 5.8. Running the below with 5.7 correctly calls the promise once, while running it with 5.8 calls it twice.
<head> <script src="https://browser.sentry-cdn.com/5.14.2/bundle.min.js"></script> <script type=""> var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var WrappedFetchTransport = /** @class */ (function (_super) { __extends(WrappedFetchTransport, _super); function WrappedFetchTransport() { return _super !== null && _super.apply(this, arguments) || this; } /** * @inheritDoc */ WrappedFetchTransport.prototype.sendEvent = function (event) { var promise = _super.prototype.sendEvent.call(this, event); promise.then(function () { console.log("success"); }, function (response) { console.log("error"); }); return promise; }; return WrappedFetchTransport; }(Sentry.Transports.FetchTransport)); Sentry.init({ dsn: '__SENTRY_DSN__', transport: WrappedFetchTransport }); throw Error("its an error"); </script> </head> <body> <h1>Hi</hi> </body> </html>christopher-taormina-zocdoc commented
on Mar 25, 2020 AuthorMore actions@kamilogorek will this fix be released soon?
@christopher-taormina-zocdoc sometime tomorrow (thursday). I'll ping you.
@christopher-taormina-zocdoc released as
5.15.1christopher-taormina-zocdoc commented
on Mar 26, 2020 AuthorMore actionsAwesome, thanks!
Package + Version
@sentry/browser@sentry/noderaven-jsraven-node(raven for node)Version:
Description
I'm working on setting up Sentry in a React application and extending the FetchTransport to add a metric on the response of the request sentry.io. Debugging through the application shows my promise being invoked twice for each sendEvent call of the transport. A simplified version of my transport that still displays this is as follows: