@powerhousedao/registry 6.2.3-dev.77 → 6.2.3-dev.79

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/cli.mjs CHANGED
@@ -2,7 +2,7 @@ import { $ as HttpResponse, B as init_transport, C as dateToUtcString, E as toUt
2
2
  import { createRequire } from "node:module";
3
3
  import { binary, command, flag, number, option, optional, run, string } from "cmd-ts";
4
4
  import { DeleteObjectCommand, DeleteObjectsCommand, GetObjectCommand, HeadObjectCommand, ListObjectsV2Command, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
5
- import { API_ERROR, HEADERS, authUtils, errorUtils, fileUtils, pluginUtils, validationUtils } from "@verdaccio/core";
5
+ import { API_ERROR, HEADERS, HTTP_STATUS, authUtils, errorUtils, fileUtils, pluginUtils, validationUtils } from "@verdaccio/core";
6
6
  import crypto, { randomBytes, randomUUID } from "node:crypto";
7
7
  import fs, { readFileSync } from "node:fs";
8
8
  import os, { homedir } from "node:os";
@@ -16656,6 +16656,7 @@ function abortTarballOnClose(req, res, next) {
16656
16656
  //#region src/uplink-miss-cache.ts
16657
16657
  const UPLINK_MISS_CACHE_LIMIT = 1e4;
16658
16658
  const WRAPPED = Symbol.for("powerhouse.registry.uplinkMissCache");
16659
+ const FAILURES_WRAPPED = Symbol.for("powerhouse.registry.uplinkFailures");
16659
16660
  function packageDir(fromDir, pkg) {
16660
16661
  const entry = createRequire(path.join(fromDir, "noop.js")).resolve(pkg);
16661
16662
  let dir = path.dirname(entry);
@@ -16708,12 +16709,28 @@ function wrapGetRemoteMetadata(proto, limit) {
16708
16709
  wrapped[WRAPPED] = true;
16709
16710
  proto.getRemoteMetadata = wrapped;
16710
16711
  }
16711
- async function installUplinkMissCache(limit = UPLINK_MISS_CACHE_LIMIT) {
16712
+ function wrapUplinkFailures(proto) {
16713
+ const original = proto.getRemoteMetadata;
16714
+ if (original[FAILURES_WRAPPED]) return;
16715
+ const wrapped = async function(name, options) {
16716
+ try {
16717
+ return await original.call(this, name, options);
16718
+ } catch (err) {
16719
+ const code = err?.code;
16720
+ if (isUplinkNotFound(err) || code === HTTP_STATUS.NOT_MODIFIED || code === HTTP_STATUS.SERVICE_UNAVAILABLE) throw err;
16721
+ throw errorUtils.getServiceUnavailable(err?.message ?? String(err));
16722
+ }
16723
+ };
16724
+ wrapped[FAILURES_WRAPPED] = true;
16725
+ proto.getRemoteMetadata = wrapped;
16726
+ }
16727
+ async function installUplinkWrappers(limit = UPLINK_MISS_CACHE_LIMIT) {
16712
16728
  const proxy = entries(packageDir(packageDir(packageDir(import.meta.dirname, "verdaccio"), "@verdaccio/store"), "@verdaccio/proxy"));
16713
16729
  const esm = await import(pathToFileURL(proxy.esm).href);
16714
16730
  const cjs = createRequire(proxy.cjs)(proxy.cjs);
16715
16731
  for (const mod of [esm, cjs]) {
16716
16732
  if (!mod.ProxyStorage) throw new Error("[registry] @verdaccio/proxy no longer exports ProxyStorage");
16733
+ wrapUplinkFailures(mod.ProxyStorage.prototype);
16717
16734
  wrapGetRemoteMetadata(mod.ProxyStorage.prototype, limit);
16718
16735
  }
16719
16736
  }
@@ -16750,6 +16767,7 @@ function buildVerdaccioConfig(config) {
16750
16767
  url: uplinkUrl,
16751
16768
  maxage: config.uplinkMaxage ?? "2m",
16752
16769
  timeout: "30s",
16770
+ fail_timeout: "0s",
16753
16771
  cache: true
16754
16772
  } },
16755
16773
  packages: (() => {
@@ -17176,7 +17194,7 @@ async function runRegistry(args) {
17176
17194
  ...authStoreToken ? { authStoreToken } : {}
17177
17195
  };
17178
17196
  if (s3 && databaseUrl) await seedVerdaccioSecret(databaseUrl, verdaccioSecret);
17179
- await installUplinkMissCache();
17197
+ await installUplinkWrappers();
17180
17198
  const verdaccioConfig = buildVerdaccioConfig(config);
17181
17199
  const verdaccioServer = await runServer(verdaccioConfig);
17182
17200
  if (authStoreToken && !wasStoreLoaded(authStoreToken)) {