@remit/backend 0.0.140 → 0.0.142

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.
@@ -0,0 +1,24 @@
1
+ import assert from "node:assert/strict";
2
+ import type { Server } from "node:http";
3
+ import { after, before, it } from "node:test";
4
+ import { UPSTREAM_KEEPALIVE_IDLE_TIMEOUT_SECONDS } from "@remit/apisix/route-table";
5
+
6
+ let server: Server;
7
+
8
+ before(async () => {
9
+ process.env.BETTER_AUTH_SECRET = "a-signing-secret-of-at-least-32-characters";
10
+ process.env.CORS_ALLOWED_ORIGINS = "https://mail.example.com";
11
+ process.env.SERVER_PORT = "0";
12
+ server = (await import("./server.js")).listener;
13
+ });
14
+
15
+ after(async () => {
16
+ await new Promise<void>((resolve) => server.close(() => resolve()));
17
+ });
18
+
19
+ it("keeps an idle socket open longer than the APISIX upstream pool does", () => {
20
+ assert.ok(
21
+ server.keepAliveTimeout > UPSTREAM_KEEPALIVE_IDLE_TIMEOUT_SECONDS * 1_000,
22
+ `backend keepAliveTimeout ${server.keepAliveTimeout}ms must exceed APISIX idle_timeout ${UPSTREAM_KEEPALIVE_IDLE_TIMEOUT_SECONDS}s`,
23
+ );
24
+ });
@@ -378,4 +378,7 @@ export const listener = app.listen(Number(port), "0.0.0.0", () => {
378
378
  process.send?.("ready");
379
379
  });
380
380
 
381
+ // Outlasts the idle timeout of every proxy that reuses connections to it.
382
+ listener.keepAliveTimeout = 65_000;
383
+
381
384
  export default app;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/backend",
3
- "version": "0.0.140",
3
+ "version": "0.0.142",
4
4
  "description": "Remit Mail Inspector API backend",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -54,6 +54,7 @@
54
54
  "serve": "node --import tsx dev-server/server.ts"
55
55
  },
56
56
  "devDependencies": {
57
+ "@remit/apisix": "*",
57
58
  "@types/better-sqlite3": "^7.6.13",
58
59
  "@types/express": "^5.0.3",
59
60
  "@types/swagger-ui-express": "^4.1.8",
@@ -57,9 +57,7 @@ export const triggerSyncSafe = async (
57
57
  // POST /sync asks for a sync of this account by name — the refresh
58
58
  // control, pull-to-refresh, and the client's automatic poll all land
59
59
  // here — so it syncs every mailbox regardless of how recently one
60
- // ran. The poll's cadence is floored client-side at the fan-out
61
- // gate's window, so this branch cannot be driven faster than the
62
- // gate would allow.
60
+ // ran.
63
61
  explicitRequest: true,
64
62
  });
65
63
  deps.logger.info(