@sentry/core
Advanced tools
Comparing version
@@ -54,2 +54,4 @@ import { Scope } from '@sentry/hub'; | ||
protected _processing: boolean; | ||
/** Processing interval */ | ||
protected _processingInterval?: number; | ||
/** | ||
@@ -99,3 +101,3 @@ * Initializes this client instance. | ||
/** Waits for the client to be done with processing. */ | ||
protected _isClientProcessing(counter?: number): Promise<boolean>; | ||
protected _isClientProcessing(timeout?: number): Promise<boolean>; | ||
/** Returns the current backend. */ | ||
@@ -102,0 +104,0 @@ protected _getBackend(): B; |
@@ -136,11 +136,17 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var clientReady, transportFlushed; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, Promise.all([ | ||
this._getBackend() | ||
case 0: return [4 /*yield*/, this._isClientProcessing(timeout)]; | ||
case 1: | ||
clientReady = _a.sent(); | ||
if (this._processingInterval) { | ||
clearInterval(this._processingInterval); | ||
} | ||
return [4 /*yield*/, this._getBackend() | ||
.getTransport() | ||
.close(timeout), | ||
this._isClientProcessing(), | ||
])]; | ||
case 1: return [2 /*return*/, (_a.sent()).reduce(function (prev, current) { return prev && current; })]; | ||
.close(timeout)]; | ||
case 2: | ||
transportFlushed = _a.sent(); | ||
return [2 /*return*/, clientReady && transportFlushed]; | ||
} | ||
@@ -155,7 +161,5 @@ }); | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.flush(timeout).finally(function () { | ||
_this.getOptions().enabled = false; | ||
})]; | ||
this.getOptions().enabled = false; | ||
return [2 /*return*/, this.flush(timeout)]; | ||
}); | ||
@@ -183,4 +187,3 @@ }); | ||
/** Waits for the client to be done with processing. */ | ||
BaseClient.prototype._isClientProcessing = function (counter) { | ||
if (counter === void 0) { counter = 0; } | ||
BaseClient.prototype._isClientProcessing = function (timeout) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -190,26 +193,18 @@ var _this = this; | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
if (_this._processing) { | ||
// Safeguard in case of endless recursion | ||
if (counter >= 10) { | ||
resolve(false); | ||
var ticked = 0; | ||
var tick = 1; | ||
if (_this._processingInterval) { | ||
clearInterval(_this._processingInterval); | ||
} | ||
_this._processingInterval = setInterval(function () { | ||
if (!_this._processing) { | ||
resolve(true); | ||
} | ||
else { | ||
setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var _a; | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = resolve; | ||
return [4 /*yield*/, this._isClientProcessing(counter + 1)]; | ||
case 1: | ||
_a.apply(void 0, [_b.sent()]); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }, 10); | ||
ticked += tick; | ||
if (timeout && ticked >= timeout) { | ||
resolve(false); | ||
} | ||
} | ||
} | ||
else { | ||
resolve(true); | ||
} | ||
}, tick); | ||
})]; | ||
@@ -216,0 +211,0 @@ }); |
@@ -54,2 +54,4 @@ import { Scope } from '@sentry/hub'; | ||
protected _processing: boolean; | ||
/** Processing interval */ | ||
protected _processingInterval?: number; | ||
/** | ||
@@ -99,3 +101,3 @@ * Initializes this client instance. | ||
/** Waits for the client to be done with processing. */ | ||
protected _isClientProcessing(counter?: number): Promise<boolean>; | ||
protected _isClientProcessing(timeout?: number): Promise<boolean>; | ||
/** Returns the current backend. */ | ||
@@ -102,0 +104,0 @@ protected _getBackend(): B; |
@@ -134,11 +134,17 @@ import * as tslib_1 from "tslib"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var clientReady, transportFlushed; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, Promise.all([ | ||
this._getBackend() | ||
case 0: return [4 /*yield*/, this._isClientProcessing(timeout)]; | ||
case 1: | ||
clientReady = _a.sent(); | ||
if (this._processingInterval) { | ||
clearInterval(this._processingInterval); | ||
} | ||
return [4 /*yield*/, this._getBackend() | ||
.getTransport() | ||
.close(timeout), | ||
this._isClientProcessing(), | ||
])]; | ||
case 1: return [2 /*return*/, (_a.sent()).reduce(function (prev, current) { return prev && current; })]; | ||
.close(timeout)]; | ||
case 2: | ||
transportFlushed = _a.sent(); | ||
return [2 /*return*/, clientReady && transportFlushed]; | ||
} | ||
@@ -153,7 +159,5 @@ }); | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.flush(timeout).finally(function () { | ||
_this.getOptions().enabled = false; | ||
})]; | ||
this.getOptions().enabled = false; | ||
return [2 /*return*/, this.flush(timeout)]; | ||
}); | ||
@@ -181,4 +185,3 @@ }); | ||
/** Waits for the client to be done with processing. */ | ||
BaseClient.prototype._isClientProcessing = function (counter) { | ||
if (counter === void 0) { counter = 0; } | ||
BaseClient.prototype._isClientProcessing = function (timeout) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -188,26 +191,18 @@ var _this = this; | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
if (_this._processing) { | ||
// Safeguard in case of endless recursion | ||
if (counter >= 10) { | ||
resolve(false); | ||
var ticked = 0; | ||
var tick = 1; | ||
if (_this._processingInterval) { | ||
clearInterval(_this._processingInterval); | ||
} | ||
_this._processingInterval = setInterval(function () { | ||
if (!_this._processing) { | ||
resolve(true); | ||
} | ||
else { | ||
setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var _a; | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = resolve; | ||
return [4 /*yield*/, this._isClientProcessing(counter + 1)]; | ||
case 1: | ||
_a.apply(void 0, [_b.sent()]); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }, 10); | ||
ticked += tick; | ||
if (timeout && ticked >= timeout) { | ||
resolve(false); | ||
} | ||
} | ||
} | ||
else { | ||
resolve(true); | ||
} | ||
}, tick); | ||
})]; | ||
@@ -214,0 +209,0 @@ }); |
{ | ||
"name": "@sentry/core", | ||
"version": "5.0.6", | ||
"version": "5.0.7", | ||
"description": "Base implementation for all Sentry JavaScript SDKs", | ||
@@ -19,6 +19,6 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/hub": "5.0.6", | ||
"@sentry/minimal": "5.0.6", | ||
"@sentry/hub": "5.0.7", | ||
"@sentry/minimal": "5.0.7", | ||
"@sentry/types": "5.0.6", | ||
"@sentry/utils": "5.0.6", | ||
"@sentry/utils": "5.0.7", | ||
"tslib": "^1.9.3" | ||
@@ -25,0 +25,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
228790
-0.01%2643
-0.23%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated
Updated
Updated