Skip to content

Commit a7b64b4

Browse files
committed
fix: frigade has not been initialized error
1 parent 2396de0 commit a7b64b4

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

.changeset/itchy-plums-destroy.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@frigade/js": patch
3+
"@frigade/react": patch
4+
---
5+
6+
Fixes an edge case where in some cases, the error `Frigade has not yet been initialized` can occur.

packages/js-api/src/core/frigade.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ export class Frigade extends Fetchable {
7272
* @ignore
7373
*/
7474
private queueRefreshStateFromAPI() {
75+
if (!this.isReady()) {
76+
return
77+
}
78+
7579
this.queuedRefresh = true
7680
if (this.refreshTimeout) {
7781
return
@@ -280,7 +284,12 @@ export class Frigade extends Fetchable {
280284
* @ignore
281285
*/
282286
public isReady(): boolean {
283-
return Boolean(this.config.__instanceId && this.config.apiKey && this.initPromise)
287+
return Boolean(
288+
this.config.__instanceId &&
289+
this.config.apiKey &&
290+
this.initPromise &&
291+
frigadeGlobalState[getGlobalStateKey(this.config)]
292+
)
284293
}
285294

286295
/**

0 commit comments

Comments
 (0)