@tscircuit/parts-engine 0.0.31 → 0.0.32

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/dist/index.js CHANGED
@@ -12339,12 +12339,23 @@ var getJlcPartsCached = async (name, params) => {
12339
12339
  if (cache.has(paramString)) {
12340
12340
  return cache.get(paramString);
12341
12341
  }
12342
- const response = await fetch(
12343
- `https://jlcsearch.tscircuit.com/${name}/list?${paramString}`
12344
- );
12345
- const responseJson = await response.json();
12346
- cache.set(paramString, responseJson);
12347
- return responseJson;
12342
+ const requestPromise = (async () => {
12343
+ const response = await fetch(
12344
+ `https://jlcsearch.tscircuit.com/${name}/list?${paramString}`
12345
+ );
12346
+ return response.json();
12347
+ })();
12348
+ cache.set(paramString, requestPromise);
12349
+ try {
12350
+ const responseJson = await requestPromise;
12351
+ cache.set(paramString, responseJson);
12352
+ return responseJson;
12353
+ } catch (error) {
12354
+ if (cache.get(paramString) === requestPromise) {
12355
+ cache.delete(paramString);
12356
+ }
12357
+ throw error;
12358
+ }
12348
12359
  };
12349
12360
  var withBasicPartPreference = (parts) => {
12350
12361
  if (!parts) return [];