diff --git a/packages/daemon/src/daemon-node-powers.js b/packages/daemon/src/daemon-node-powers.js index 260694f905..7182ba97e4 100644 --- a/packages/daemon/src/daemon-node-powers.js +++ b/packages/daemon/src/daemon-node-powers.js @@ -244,13 +244,22 @@ export const makeNetworkPowers = ({ http, ws, net }) => { * @param {Promise} args.cancelled */ const servePath = async ({ path, cancelled }) => - serveListener( - server => - new Promise(resolve => - server.listen({ path }, () => resolve(undefined)), - ), - cancelled, - ); + serveListener(server => { + return new Promise((resolve, reject) => + server.listen({ path }, error => { + if (error) { + if (path.length >= 104) { + console.warn( + `Warning: Length of path for domain socket or named path exceeeds common maximum (104, possibly 108) for some platforms (length: ${path.length}, path: ${path})`, + ); + } + reject(error); + } else { + resolve(undefined); + } + }), + ); + }, cancelled); const connectionNumbers = (function* generateNumbers() { let n = 0; @@ -265,7 +274,7 @@ export const makeNetworkPowers = ({ http, ws, net }) => { * @param {string} sockPath * @param {Promise} cancelled * @param {(error: Error) => void} exitWithError - * @returns {{ started: () => Promise, stopped: Promise }} + * @returns {{ started: Promise, stopped: Promise }} */ const makePrivatePathService = ( endoBootstrap, @@ -288,7 +297,7 @@ export const makeNetworkPowers = ({ http, ws, net }) => { * @param {(port: Promise) => void} assignWebletPort * @param {Promise} cancelled * @param {(error: Error) => void} exitWithError - * @returns {{ started: () => Promise, stopped: Promise }} + * @returns {{ started: Promise, stopped: Promise }} */ const makePrivateHttpService = ( endoBootstrap, diff --git a/packages/daemon/src/daemon.js b/packages/daemon/src/daemon.js index 5cc5d45b4f..eb7f7ef5b8 100644 --- a/packages/daemon/src/daemon.js +++ b/packages/daemon/src/daemon.js @@ -407,7 +407,7 @@ const makeEndoBootstrap = ( formula, ); - // Memoize provide. + // Memoize for lookup. valuePromiseForFormulaIdentifier.set(formulaIdentifier, promiseForValue); // Prepare an entry for reverse-lookup of formula for presence. diff --git a/packages/daemon/src/serve-private-path.js b/packages/daemon/src/serve-private-path.js index fb6629c397..4e095126a9 100644 --- a/packages/daemon/src/serve-private-path.js +++ b/packages/daemon/src/serve-private-path.js @@ -11,15 +11,15 @@ export const servePrivatePath = ( ) => { const connectionsP = servePath({ path: sockPath, cancelled }); - const started = async () => { + const started = (async () => { await connectionsP; // Resolve a promise in the Endo CLI through the IPC channel: console.log( - `Endo daemon listening for CapTP on ${q( + `Endo daemon listening for private CapTP on ${q( sockPath, )} ${new Date().toISOString()}`, ); - }; + })(); const stopped = (async () => { /** @type {Set>} */ @@ -33,7 +33,7 @@ export const servePrivatePath = ( closed: connectionClosed, } of connections) { (async () => { - const connectionNumber = connectionNumbers.next(); + const { value: connectionNumber } = connectionNumbers.next(); console.log( `Endo daemon received domain connection ${connectionNumber} at ${new Date().toISOString()}`, ); diff --git a/packages/daemon/src/serve-private-port-http.js b/packages/daemon/src/serve-private-port-http.js index 9344196c6a..80131d8f42 100644 --- a/packages/daemon/src/serve-private-port-http.js +++ b/packages/daemon/src/serve-private-port-http.js @@ -65,7 +65,7 @@ export const servePrivatePortHttp = ( closed: connectionClosed, } = connection; - const connectionNumber = connectionNumbers.next(); + const { value: connectionNumber } = connectionNumbers.next(); console.log( `Endo daemon received local web socket connection ${connectionNumber} at ${new Date().toISOString()}`, ); diff --git a/packages/daemon/src/types.d.ts b/packages/daemon/src/types.d.ts index bdc337e19f..ade4ee1b7b 100644 --- a/packages/daemon/src/types.d.ts +++ b/packages/daemon/src/types.d.ts @@ -271,14 +271,14 @@ export type NetworkPowers = { sockPath: string, cancelled: Promise, exitWithError: (error: Error) => void, - ) => { started: () => Promise; stopped: Promise }; + ) => { started: Promise; stopped: Promise }; makePrivateHttpService: ( endoBootstrap: FarRef, port: number, assignWebletPort: (portP: Promise) => void, cancelled: Promise, exitWithError: (error: Error) => void, - ) => { started: () => Promise; stopped: Promise }; + ) => { started: Promise; stopped: Promise }; }; // The return type here is almost an EndoReadable, but not quite. Should fix.