@lasso-ai/cli 1.0.3 → 1.0.5

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.
@@ -25,6 +25,30 @@ function freePort() {
25
25
  });
26
26
  });
27
27
  }
28
+ function waitForNext(nextPort, timeoutMs = 60_000) {
29
+ const deadline = Date.now() + timeoutMs;
30
+ return new Promise((resolve, reject) => {
31
+ const check = () => {
32
+ const request = node_http_1.default.get({
33
+ hostname: "127.0.0.1",
34
+ port: nextPort,
35
+ path: "/",
36
+ headers: { connection: "close" },
37
+ }, (response) => {
38
+ response.resume();
39
+ response.once("end", resolve);
40
+ });
41
+ request.once("error", () => {
42
+ if (Date.now() >= deadline) {
43
+ reject(new Error(`Next.js did not become ready on port ${nextPort} within ${timeoutMs / 1000}s.`));
44
+ return;
45
+ }
46
+ setTimeout(check, 250);
47
+ });
48
+ };
49
+ check();
50
+ });
51
+ }
28
52
  void (async () => {
29
53
  const nextPort = await freePort();
30
54
  const nextBin = node_path_1.default.join(cwd, "node_modules", ".bin", "next");
@@ -66,6 +90,14 @@ void (async () => {
66
90
  });
67
91
  });
68
92
  server.on("upgrade", (req, socket, head) => proxy.ws(req, socket, head));
93
+ try {
94
+ await waitForNext(nextPort);
95
+ }
96
+ catch (error) {
97
+ bridge.close();
98
+ nextProcess.kill("SIGTERM");
99
+ throw error;
100
+ }
69
101
  server.listen(publicPort, "127.0.0.1");
70
102
  const shutdown = () => {
71
103
  bridge.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lasso-ai/cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Select any part of your running app, describe a change, and let AI edit the real source code.",
5
5
  "type": "commonjs",
6
6
  "main": "dist/cli/index.js",