lopata 0.14.0 → 0.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lopata",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/cli/dev.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  // Capture deeper stacks in dev mode (default is 10, async boundaries still truncate)
2
2
  Error.stackTraceLimit = 50
3
3
 
4
+ // Prevent unhandled rejections from worker code from crashing the dev server
5
+ process.on('unhandledRejection', (reason) => {
6
+ console.error('[lopata] Unhandled promise rejection:', reason)
7
+ })
8
+
4
9
  import '../plugin'
5
10
  import path from 'node:path'
6
11
  import {
@@ -197,7 +197,7 @@ export function devServerPlugin(options: DevServerPluginOptions): Plugin {
197
197
  }
198
198
  })) as Response
199
199
 
200
- writeResponse(response, res)
200
+ writeResponse(response, res).catch(() => {})
201
201
  } finally {
202
202
  const count = genActiveRequests.get(genId) ?? 1
203
203
  if (count <= 1) genActiveRequests.delete(genId)
@@ -238,6 +238,11 @@ export function devServerPlugin(options: DevServerPluginOptions): Plugin {
238
238
  // Deeper stacks in dev mode
239
239
  Error.stackTraceLimit = 50
240
240
 
241
+ // Prevent unhandled rejections from worker code from crashing the dev server
242
+ process.on('unhandledRejection', (reason) => {
243
+ console.error('[lopata] Unhandled promise rejection:', reason)
244
+ })
245
+
241
246
  // Lazy import runtime modules — runs through Bun's native loader
242
247
  const configMod = await import('../config.ts')
243
248
  const envMod = await import('../env.ts')
@@ -492,7 +497,7 @@ export function devServerPlugin(options: DevServerPluginOptions): Plugin {
492
497
  try {
493
498
  const request = nodeReqToRequest(req)
494
499
  const response = await (handleApiRequest as (r: Request) => Response | Promise<Response>)(request)
495
- writeResponse(response, res)
500
+ await writeResponse(response, res)
496
501
  } catch (err) {
497
502
  console.error('[lopata:vite] API error:', err)
498
503
  if (!res.headersSent) {
@@ -508,7 +513,7 @@ export function devServerPlugin(options: DevServerPluginOptions): Plugin {
508
513
  try {
509
514
  const request = nodeReqToRequest(req)
510
515
  const response = await (handleDashboardRequest as (r: Request) => Response | Promise<Response>)(request)
511
- writeResponse(response, res)
516
+ await writeResponse(response, res)
512
517
  } catch (err) {
513
518
  console.error('[lopata:vite] Dashboard error:', err)
514
519
  if (!res.headersSent) {
@@ -543,7 +548,7 @@ export function devServerPlugin(options: DevServerPluginOptions): Plugin {
543
548
  ;(setSpanAttribute as Function)('http.status_code', resp.status)
544
549
  return resp
545
550
  }) as Response
546
- writeResponse(response, res)
551
+ await writeResponse(response, res)
547
552
  } catch (err) {
548
553
  writeRequestError(res, err)
549
554
  }
@@ -906,6 +911,8 @@ async function writeResponse(response: Response, res: ServerResponse): Promise<v
906
911
  if (done) break
907
912
  res.write(value)
908
913
  }
914
+ } catch {
915
+ // Upstream stream error (e.g. ECONNRESET) — just end the response
909
916
  } finally {
910
917
  reader.releaseLock()
911
918
  res.end()