GeezerVison is showing github.com — Fixed a bug where calling startup multiple times with a callback woul… · rchcomm/Exceptionless.JavaScript@7c465d7
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/browser/src/BrowserExceptionlessClient.ts +3-5Lines changed: 3 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,11 +8,9 @@ import { BrowserRequestInfoPlugin } from "./plugins/BrowserRequestInfoPlugin.js" |
8 | 8 | import { BrowserWrapFunctions } from "./plugins/BrowserWrapFunctions.js"; |
9 | 9 |
|
10 | 10 | export class BrowserExceptionlessClient extends ExceptionlessClient { |
11 | | - public async startup( |
12 | | - configurationOrApiKey?: (config: Configuration) => void | string, |
13 | | - ): Promise<void> { |
| 11 | + public async startup(configurationOrApiKey?: (config: Configuration) => void | string): Promise<void> { |
14 | 12 | const config = this.config; |
15 | | - if (configurationOrApiKey) { |
| 13 | + if (configurationOrApiKey && !this._initialized) { |
16 | 14 | config.useLocalStorage(); |
17 | 15 |
|
18 | 16 | config.addPlugin(new BrowserGlobalHandlerPlugin()); |
@@ -24,7 +22,7 @@ export class BrowserExceptionlessClient extends ExceptionlessClient { |
24 | 22 | } |
25 | 23 |
|
26 | 24 | await super.startup(configurationOrApiKey); |
27 | | - if (configurationOrApiKey) { |
| 25 | + if (configurationOrApiKey && !this._initialized) { |
28 | 26 | config.removePlugin(new SimpleErrorPlugin()); |
29 | 27 | } |
30 | 28 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/core/src/ExceptionlessClient.ts +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,12 +11,14 @@ import { PluginContext } from "./plugins/PluginContext.js"; |
11 | 11 | export class ExceptionlessClient { |
12 | 12 | private _intervalId = 0; |
13 | 13 | private _timeoutId = 0; |
| 14 | + protected _initialized = false; |
14 | 15 |
|
15 | 16 | public constructor(public config: Configuration = new Configuration()) { } |
16 | 17 |
|
17 | 18 | /** Resume background submission, resume any timers. */ |
18 | 19 | public async startup(configurationOrApiKey?: (config: Configuration) => void | string): Promise<void> { |
19 | | - if (configurationOrApiKey) { |
| 20 | + if (configurationOrApiKey && !this._initialized) { |
| 21 | + this._initialized = true; |
20 | 22 | EventPluginManager.addDefaultPlugins(this.config); |
21 | 23 |
|
22 | 24 | if (typeof configurationOrApiKey === "string") { |
@@ -33,6 +35,7 @@ export class ExceptionlessClient { |
33 | 35 |
|
34 | 36 | this.updateSettingsTimer(!!configurationOrApiKey); |
35 | 37 | await EventPluginManager.startup(new PluginContext(this)); |
| 38 | + |
36 | 39 | const { queue } = this.config.services; |
37 | 40 | await queue.startup(); |
38 | 41 | if (this.config.usePersistedQueueStorage) { |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/node/src/NodeExceptionlessClient.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,7 @@ export class NodeExceptionlessClient extends ExceptionlessClient { |
20 | 20 | public async startup(configurationOrApiKey?: (config: Configuration) => void | string): Promise<void> { |
21 | 21 | const config = this.config; |
22 | 22 |
|
23 | | - if (configurationOrApiKey) { |
| 23 | + if (configurationOrApiKey && !this._initialized) { |
24 | 24 | if (!globalThis?.localStorage) { |
25 | 25 | const storage = new LocalStorage(undefined, new LocalStoragePolyfill(process.cwd() + '/.exceptionless')); |
26 | 26 | config.useLocalStorage = () => storage; |
@@ -43,7 +43,7 @@ export class NodeExceptionlessClient extends ExceptionlessClient { |
43 | 43 |
|
44 | 44 | await super.startup(configurationOrApiKey); |
45 | 45 |
|
46 | | - if (configurationOrApiKey) { |
| 46 | + if (configurationOrApiKey && !this._initialized) { |
47 | 47 | config.removePlugin(new SimpleErrorPlugin()); |
48 | 48 | } |
49 | 49 | } |
|