sapper-iq 1.2.2 → 1.2.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/package.json +1 -1
- package/sapper-ui.mjs +29 -2
package/package.json
CHANGED
package/sapper-ui.mjs
CHANGED
|
@@ -2839,8 +2839,33 @@ function startStatsPoll() {
|
|
|
2839
2839
|
|
|
2840
2840
|
// ─── Launch ──────────────────────────────────────────────────────
|
|
2841
2841
|
|
|
2842
|
-
|
|
2843
|
-
|
|
2842
|
+
const PORT_RETRY_LIMIT = parseInt(process.env.SAPPER_UI_PORT_RETRIES || '20', 10);
|
|
2843
|
+
const portExplicit = !!process.env.SAPPER_UI_PORT;
|
|
2844
|
+
let portAttempt = 0;
|
|
2845
|
+
let activePort = PORT;
|
|
2846
|
+
|
|
2847
|
+
function tryListen(port) {
|
|
2848
|
+
activePort = port;
|
|
2849
|
+
server.listen(port);
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
server.on('error', (err) => {
|
|
2853
|
+
if (err && err.code === 'EADDRINUSE' && portAttempt < PORT_RETRY_LIMIT) {
|
|
2854
|
+
portAttempt++;
|
|
2855
|
+
const next = activePort + 1;
|
|
2856
|
+
const reason = portExplicit
|
|
2857
|
+
? `port ${activePort} (from SAPPER_UI_PORT) is in use`
|
|
2858
|
+
: `port ${activePort} is in use`;
|
|
2859
|
+
console.log(` \x1b[33m⚠\x1b[0m ${reason}, trying ${next}…`);
|
|
2860
|
+
setTimeout(() => tryListen(next), 50);
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
console.error(`\n \x1b[31m✖ Sapper Web failed to start:\x1b[0m ${err && err.message ? err.message : err}`);
|
|
2864
|
+
process.exit(1);
|
|
2865
|
+
});
|
|
2866
|
+
|
|
2867
|
+
server.on('listening', () => {
|
|
2868
|
+
const url = `http://localhost:${activePort}`;
|
|
2844
2869
|
console.log(`\n \x1b[36m⚡ Sapper Web\x1b[0m running at \x1b[1m${url}\x1b[0m`);
|
|
2845
2870
|
console.log(` Working dir: ${workingDir}\n`);
|
|
2846
2871
|
startWatcher();
|
|
@@ -2864,5 +2889,7 @@ server.listen(PORT, () => {
|
|
|
2864
2889
|
}
|
|
2865
2890
|
});
|
|
2866
2891
|
|
|
2892
|
+
tryListen(PORT);
|
|
2893
|
+
|
|
2867
2894
|
process.on('SIGINT', () => { console.log('\nShutting down…'); try { watcher && watcher.close(); } catch {} process.exit(0); });
|
|
2868
2895
|
process.on('SIGTERM', () => process.exit(0));
|