@@ -158,33 +158,32 @@ export class DebounceHook<T extends FlagValue = FlagValue> implements Hook {
158
158
// the cache key is a concatenation of the result of calling keyGenCallback and the stage
159
159
const dynamicKey = keyGenCallback ( ) ;
160
160
161
- // if the keyGenCallback returns nothing, we don't do any caching
162
- if ( dynamicKey ) {
163
- const cacheKeySuffix = stage ;
164
- const cacheKey = `${ dynamicKey } ::${ cacheKeySuffix } ` ;
165
- const got = this . cache . get ( cacheKey ) ;
161
+ // if the keyGenCallback returns nothing, we don't do any caching
162
+ if ( ! dynamicKey ) {
163
+ hookCallback . call ( this . innerHook ) ;
164
+ }
165
+
166
+ const cacheKeySuffix = stage ;
167
+ const cacheKey = `${ dynamicKey } ::${ cacheKeySuffix } ` ;
168
+ const got = this . cache . get ( cacheKey ) ;
166
169
167
- if ( got ) {
168
- // throw cached errors
169
- if ( got instanceof CachedError ) {
170
- throw got ;
171
- }
172
- return ;
173
- } else {
174
- try {
175
- hookCallback . call ( this . innerHook ) ;
176
- this . cache . set ( cacheKey , true ) ;
177
- } catch ( error : unknown ) {
178
- if ( this . cacheErrors ) {
179
- // cache error
180
- this . cache . set ( cacheKey , new CachedError ( error ) ) ;
181
- }
182
- throw error ;
183
- }
184
- return ;
170
+ if ( got ) {
171
+ // throw cached errors
172
+ if ( got instanceof CachedError ) {
173
+ throw got ;
185
174
}
186
- } else {
175
+ return ;
176
+ }
177
+
178
+ try {
187
179
hookCallback . call ( this . innerHook ) ;
188
- }
180
+ this . cache . set ( cacheKey , true ) ;
181
+ } catch ( error : unknown ) {
182
+ if ( this . cacheErrors ) {
183
+ // cache error
184
+ this . cache . set ( cacheKey , new CachedError ( error ) ) ;
185
+ }
186
+ throw error ;
187
+ }
189
188
}
190
189
}
0 commit comments