@astroscope/boot 0.2.1 → 0.2.2

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/dist/index.cjs CHANGED
@@ -230,8 +230,24 @@ function boot(options = {}) {
230
230
  const bootImport = `globalThis.__astroscope_server_url = import.meta.url;
231
231
  import * as __boot from './${bootChunkName}';
232
232
  const __bootContext = { dev: false, host: process.env.HOST ?? '${host}', port: process.env.PORT ? Number(process.env.PORT) : ${port} };
233
- await __boot.onStartup?.(__bootContext);
234
- if (__boot.onShutdown) process.on('SIGTERM', async () => { await __boot.onShutdown(__bootContext); process.exit(0); });
233
+ try {
234
+ await __boot.onStartup?.(__bootContext);
235
+ } catch (err) {
236
+ console.error('[boot] startup failed:', err);
237
+ try { await __boot.onShutdown?.(__bootContext); } catch {}
238
+ process.exit(1);
239
+ }
240
+ if (__boot.onShutdown) {
241
+ process.on('SIGTERM', async () => {
242
+ try {
243
+ await __boot.onShutdown(__bootContext);
244
+ process.exit(0);
245
+ } catch (err) {
246
+ console.error('[boot] shutdown failed:', err);
247
+ process.exit(1);
248
+ }
249
+ });
250
+ }
235
251
  `;
236
252
  const s = new import_magic_string.default(entryChunk.code);
237
253
  s.prepend(bootImport);
package/dist/index.js CHANGED
@@ -193,8 +193,24 @@ function boot(options = {}) {
193
193
  const bootImport = `globalThis.__astroscope_server_url = import.meta.url;
194
194
  import * as __boot from './${bootChunkName}';
195
195
  const __bootContext = { dev: false, host: process.env.HOST ?? '${host}', port: process.env.PORT ? Number(process.env.PORT) : ${port} };
196
- await __boot.onStartup?.(__bootContext);
197
- if (__boot.onShutdown) process.on('SIGTERM', async () => { await __boot.onShutdown(__bootContext); process.exit(0); });
196
+ try {
197
+ await __boot.onStartup?.(__bootContext);
198
+ } catch (err) {
199
+ console.error('[boot] startup failed:', err);
200
+ try { await __boot.onShutdown?.(__bootContext); } catch {}
201
+ process.exit(1);
202
+ }
203
+ if (__boot.onShutdown) {
204
+ process.on('SIGTERM', async () => {
205
+ try {
206
+ await __boot.onShutdown(__bootContext);
207
+ process.exit(0);
208
+ } catch (err) {
209
+ console.error('[boot] shutdown failed:', err);
210
+ process.exit(1);
211
+ }
212
+ });
213
+ }
198
214
  `;
199
215
  const s = new MagicString(entryChunk.code);
200
216
  s.prepend(bootImport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astroscope/boot",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Startup and graceful shutdown hooks for Astro SSR",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",