@getmonoceros/workbench 1.7.2 → 1.7.3

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/bin.js CHANGED
@@ -824,22 +824,42 @@ function proxyUrlsFor(name, ports, hostPort = 80) {
824
824
  }
825
825
 
826
826
  // src/proxy/port-check.ts
827
- import { createServer } from "net";
827
+ import { Socket } from "net";
828
+ var CONNECT_TIMEOUT_MS = 750;
828
829
  var realPortProbe = (port) => {
829
830
  return new Promise((resolve) => {
830
- const server = createServer();
831
- server.unref();
832
- server.once("error", (err) => {
833
- resolve({
831
+ const socket = new Socket();
832
+ let settled = false;
833
+ const settle = (result) => {
834
+ if (settled) return;
835
+ settled = true;
836
+ socket.destroy();
837
+ resolve(result);
838
+ };
839
+ socket.setTimeout(CONNECT_TIMEOUT_MS);
840
+ socket.once("connect", () => {
841
+ settle({
834
842
  ok: false,
835
- code: err.code ?? "UNKNOWN",
836
- message: err.message
843
+ code: "EADDRINUSE",
844
+ message: `another process is listening on ${port}`
837
845
  });
838
846
  });
839
- server.once("listening", () => {
840
- server.close(() => resolve({ ok: true }));
847
+ socket.once("timeout", () => {
848
+ settle({ ok: true });
841
849
  });
842
- server.listen(port, "0.0.0.0");
850
+ socket.once("error", (err) => {
851
+ const code = err.code ?? "UNKNOWN";
852
+ if (code === "ECONNREFUSED") {
853
+ settle({ ok: true });
854
+ } else {
855
+ settle({
856
+ ok: false,
857
+ code,
858
+ message: err.message
859
+ });
860
+ }
861
+ });
862
+ socket.connect(port, "127.0.0.1");
843
863
  });
844
864
  };
845
865
  async function preflightHostPort(hostPort, opts = {}) {
@@ -887,16 +907,16 @@ function formatHostPortHeldError(hostPort, code, systemMessage) {
887
907
  lines.push("");
888
908
  lines.push(`Aborting \u2014 re-run after the conflict is resolved.`);
889
909
  } else {
890
- lines.push(`Cannot bind host port ${hostPort}: ${systemMessage}`);
910
+ lines.push(`Cannot reach host port ${hostPort}: ${systemMessage}`);
911
+ lines.push("");
912
+ lines.push(`This is not the typical "port already in use" case \u2014`);
913
+ lines.push(`Monoceros's pre-flight uses a TCP-connect probe (not a`);
914
+ lines.push(`bind), so EACCES / privileged-port errors normally don't`);
915
+ lines.push(`appear here. Most likely something on your host network`);
916
+ lines.push(`stack (firewall, network namespace, \u2026) is interfering with`);
917
+ lines.push(`loopback connects.`);
891
918
  lines.push("");
892
- if (code === "EACCES") {
893
- lines.push(`Port ${hostPort} is a privileged port (<1024) and your`);
894
- lines.push(`current Docker setup can't bind it. For rootful Docker`);
895
- lines.push(`(what Monoceros requires) this should normally work \u2014`);
896
- lines.push(`check that the docker daemon is running as root.`);
897
- lines.push("");
898
- }
899
- lines.push("You can also move Monoceros off this port by setting");
919
+ lines.push("Workaround: move Monoceros off this port by setting");
900
920
  lines.push("`routing.hostPort` in ~/.monoceros/monoceros-config.yml.");
901
921
  lines.push("");
902
922
  lines.push(`Aborting \u2014 re-run after the issue is resolved.`);
@@ -3611,7 +3631,7 @@ function warnOnDeprecatedFeatureRefs(containerFeatures, globalConfig, logger) {
3611
3631
  }
3612
3632
 
3613
3633
  // src/version.ts
3614
- var CLI_VERSION = true ? "1.7.2" : "dev";
3634
+ var CLI_VERSION = true ? "1.7.3" : "dev";
3615
3635
 
3616
3636
  // src/commands/_dispatch.ts
3617
3637
  import { consola as consola12 } from "consola";