@zeniai/client-epic-state 5.0.34-betaRR0 → 5.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/init.js +18 -3
- package/lib/init.js +18 -3
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/package.json +1 -1
package/lib/esm/init.js
CHANGED
|
@@ -57,7 +57,19 @@ export async function initializePusher(pusherClientSecret, options, headers, reI
|
|
|
57
57
|
if (pusherInitPromise && !reInitialize) {
|
|
58
58
|
return pusherInitPromise;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
// The IIFE captures `currentInit` so that, when its `finally` runs, it can
|
|
61
|
+
// identity-check before clearing the module-level `pusherInitPromise`. This
|
|
62
|
+
// matters when a reInitialize=true call overwrites `pusherInitPromise`
|
|
63
|
+
// while we're still in flight: without the identity check, our finally
|
|
64
|
+
// would clobber the newer call's slot and the next concurrent caller
|
|
65
|
+
// would bypass the dedup guard. Capture is safe because the first action
|
|
66
|
+
// inside the try is `await import(...)`, which always yields control —
|
|
67
|
+
// so the finally runs in a future microtask, after `currentInit` has
|
|
68
|
+
// already been assigned below. We declare it as `let … | undefined` so
|
|
69
|
+
// TS's definite-assignment analysis (which doesn't model the await) accepts
|
|
70
|
+
// the closure read; at runtime it's always the IIFE promise by then.
|
|
71
|
+
let currentInit = undefined;
|
|
72
|
+
currentInit = (async () => {
|
|
61
73
|
try {
|
|
62
74
|
// Dynamic import so the browser-only bundle is loaded only when this
|
|
63
75
|
// function actually runs (browser path). Works in both build outputs:
|
|
@@ -84,10 +96,13 @@ export async function initializePusher(pusherClientSecret, options, headers, reI
|
|
|
84
96
|
return pusher;
|
|
85
97
|
}
|
|
86
98
|
finally {
|
|
87
|
-
pusherInitPromise
|
|
99
|
+
if (pusherInitPromise === currentInit) {
|
|
100
|
+
pusherInitPromise = undefined;
|
|
101
|
+
}
|
|
88
102
|
}
|
|
89
103
|
})();
|
|
90
|
-
|
|
104
|
+
pusherInitPromise = currentInit;
|
|
105
|
+
return currentInit;
|
|
91
106
|
}
|
|
92
107
|
const customHandler = async (params, headers, callback) => {
|
|
93
108
|
const { socketId, channelName } = params;
|
package/lib/init.js
CHANGED
|
@@ -101,7 +101,19 @@ async function initializePusher(pusherClientSecret, options, headers, reInitiali
|
|
|
101
101
|
if (pusherInitPromise && !reInitialize) {
|
|
102
102
|
return pusherInitPromise;
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
// The IIFE captures `currentInit` so that, when its `finally` runs, it can
|
|
105
|
+
// identity-check before clearing the module-level `pusherInitPromise`. This
|
|
106
|
+
// matters when a reInitialize=true call overwrites `pusherInitPromise`
|
|
107
|
+
// while we're still in flight: without the identity check, our finally
|
|
108
|
+
// would clobber the newer call's slot and the next concurrent caller
|
|
109
|
+
// would bypass the dedup guard. Capture is safe because the first action
|
|
110
|
+
// inside the try is `await import(...)`, which always yields control —
|
|
111
|
+
// so the finally runs in a future microtask, after `currentInit` has
|
|
112
|
+
// already been assigned below. We declare it as `let … | undefined` so
|
|
113
|
+
// TS's definite-assignment analysis (which doesn't model the await) accepts
|
|
114
|
+
// the closure read; at runtime it's always the IIFE promise by then.
|
|
115
|
+
let currentInit = undefined;
|
|
116
|
+
currentInit = (async () => {
|
|
105
117
|
try {
|
|
106
118
|
// Dynamic import so the browser-only bundle is loaded only when this
|
|
107
119
|
// function actually runs (browser path). Works in both build outputs:
|
|
@@ -128,10 +140,13 @@ async function initializePusher(pusherClientSecret, options, headers, reInitiali
|
|
|
128
140
|
return pusher;
|
|
129
141
|
}
|
|
130
142
|
finally {
|
|
131
|
-
pusherInitPromise
|
|
143
|
+
if (pusherInitPromise === currentInit) {
|
|
144
|
+
pusherInitPromise = undefined;
|
|
145
|
+
}
|
|
132
146
|
}
|
|
133
147
|
})();
|
|
134
|
-
|
|
148
|
+
pusherInitPromise = currentInit;
|
|
149
|
+
return currentInit;
|
|
135
150
|
}
|
|
136
151
|
const customHandler = async (params, headers, callback) => {
|
|
137
152
|
const { socketId, channelName } = params;
|