bm2 1.0.6 → 1.0.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bm2",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "A blazing-fast, full-featured process manager built entirely on Bun native APIs. The modern PM2 replacement — zero Node.js dependencies, pure Bun performance.",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
package/src/daemon.ts CHANGED
@@ -26,7 +26,6 @@ import {
26
26
  import { ensureDirs } from "./utils";
27
27
  import { unlinkSync, existsSync } from "fs";
28
28
  import type { DaemonMessage, DaemonResponse } from "./types";
29
- import type { ServerWebSocket } from "bun";
30
29
 
31
30
  ensureDirs();
32
31
 
package/src/index.ts CHANGED
@@ -86,23 +86,32 @@ async function startDaemon(): Promise<void> {
86
86
  async function sendToDaemon(msg: DaemonMessage): Promise<DaemonResponse> {
87
87
 
88
88
  await startDaemon();
89
-
90
- const res = await fetch("http://localhost/command", {
91
- unix: DAEMON_SOCKET,
92
- method: "POST",
93
- headers: {
94
- "Content-Type": "application/json",
95
- },
96
- body: JSON.stringify(msg),
97
- });
98
89
 
99
- if (!res.ok) {
100
- throw new Error(`Daemon error: ${res.status}`);
101
- }
102
-
103
- const resJson: DaemonResponse = await res.json() as DaemonResponse;
90
+ let res;
104
91
 
105
- return resJson;
92
+ try {
93
+
94
+ res = await fetch("http://localhost/command", {
95
+ unix: DAEMON_SOCKET,
96
+ method: "POST",
97
+ headers: {
98
+ "Content-Type": "application/json",
99
+ },
100
+ body: JSON.stringify(msg),
101
+ });
102
+
103
+ if (!res.ok) {
104
+ throw new Error(`Daemon error: ${res.status}`);
105
+ }
106
+
107
+ const resJson: DaemonResponse = await res.json() as DaemonResponse;
108
+
109
+ return resJson;
110
+ } catch (e: any) {
111
+ console.log("Results returned "+res?.text())
112
+ console.log("sendToDaemon#Error:", e, e.stack)
113
+ return { type: "error", error: "Fetch Error", success: false }
114
+ }
106
115
  }
107
116
 
108
117
  // ---------------------------------------------------------------------------