ework-web 0.10.127 → 0.10.128

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +14 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-web",
3
- "version": "0.10.127",
3
+ "version": "0.10.128",
4
4
  "type": "module",
5
5
  "description": "ework-web — standalone multi-project issue tracker. Local SQLite-backed, no external API dependency. Bun + TypeScript + SSR HTML.",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -420,6 +420,9 @@ const SESSION_BATCH_RE = /^\/api\/sessions\/([A-Za-z0-9_-]+)\/batch$/;
420
420
  const server = Bun.serve({
421
421
  port: cfg.port,
422
422
  hostname: cfg.host,
423
+ // Streaming routes (translate, live tails) legitimately sit silent past the
424
+ // 10s default while upstream queues; 60s matches their in-route heartbeats.
425
+ idleTimeout: 60,
423
426
  async fetch(req, server) {
424
427
  const url = new URL(req.url);
425
428
  const ip = remoteAddr(req, server);
@@ -1009,6 +1012,16 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
1009
1012
  async start(controller) {
1010
1013
  const enc = new TextEncoder();
1011
1014
  const send = (obj: unknown) => controller.enqueue(enc.encode(JSON.stringify(obj) + "\n"));
1015
+ // Bun closes connections idle >10s by default; under model-server load
1016
+ // the first translation chunk can queue longer than that. Heartbeat
1017
+ // lines ({"s":1}) keep the connection alive and are ignored by clients.
1018
+ const heartbeat = setInterval(() => {
1019
+ try {
1020
+ send({ s: 1 });
1021
+ } catch {
1022
+ /* client disconnected */
1023
+ }
1024
+ }, 5000);
1012
1025
  try {
1013
1026
  let full = "";
1014
1027
  for await (const chunk of translateTextStream(cfg, text)) {
@@ -1019,6 +1032,7 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
1019
1032
  } catch (e) {
1020
1033
  send({ e: e instanceof Error ? e.message : String(e) });
1021
1034
  } finally {
1035
+ clearInterval(heartbeat);
1022
1036
  controller.close();
1023
1037
  }
1024
1038
  },