@bractjs/bractjs 0.1.19 → 0.1.20

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": "@bractjs/bractjs",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Production-grade SSR framework for Bun + React 19. File-based routing, streaming SSR, server actions, typed routes.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/bractjs/bractjs#readme",
@@ -222,28 +222,37 @@ export function createServer(config?: Partial<BractJSConfig>): {
222
222
  }
223
223
  };
224
224
 
225
- const gracefulShutdown = async (signal?: string) => {
225
+ const gracefulShutdown = (signal?: string) => {
226
226
  if (isShuttingDown) return;
227
227
  isShuttingDown = true;
228
228
  if (signal) console.log(`\n[bract] Received ${signal}, shutting down…`);
229
229
  try {
230
- await activeOnShutdown?.();
230
+ const result = activeOnShutdown?.();
231
+ if (result instanceof Promise) {
232
+ result.catch((err) => console.error("[bract] onShutdown error:", err)).finally(() => {
233
+ stopAdapter();
234
+ process.exit(0);
235
+ });
236
+ } else {
237
+ stopAdapter();
238
+ process.exit(0);
239
+ }
231
240
  } catch (err) {
232
241
  console.error("[bract] onShutdown error:", err);
242
+ stopAdapter();
243
+ process.exit(1);
233
244
  }
234
- stopAdapter();
235
- process.exit(0);
236
245
  };
237
246
 
238
247
  if (!signalsRegistered) {
239
248
  signalsRegistered = true;
240
- process.on("SIGTERM", () => void gracefulShutdown("SIGTERM"));
241
- process.on("SIGINT", () => void gracefulShutdown("SIGINT"));
242
- process.on("SIGUSR2", () => void gracefulShutdown("SIGUSR2"));
243
- process.on("beforeExit", () => void gracefulShutdown());
249
+ process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
250
+ process.on("SIGINT", () => gracefulShutdown("SIGINT"));
251
+ process.on("SIGUSR2", () => gracefulShutdown("SIGUSR2"));
252
+ process.on("beforeExit", () => gracefulShutdown());
244
253
  process.on("uncaughtException", (err) => {
245
254
  console.error("[bract] Uncaught exception:", err);
246
- void gracefulShutdown("uncaughtException");
255
+ gracefulShutdown("uncaughtException");
247
256
  });
248
257
  }
249
258