@rpcbase/server 0.571.0 → 0.573.0
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/dist/initServer.d.ts.map +1 -1
- package/dist/posthog.d.ts.map +1 -1
- package/dist/shutdown.d.ts +5 -0
- package/dist/shutdown.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3752,6 +3752,32 @@ class PostHog extends PostHogBackendClient {
|
|
|
3752
3752
|
return new PostHogContext();
|
|
3753
3753
|
}
|
|
3754
3754
|
}
|
|
3755
|
+
const SIGNAL_SHUTDOWN_TIMEOUT_MS = 2e3;
|
|
3756
|
+
const hooks = /* @__PURE__ */ new Set();
|
|
3757
|
+
let signalsBound = false;
|
|
3758
|
+
const runHooks = async () => {
|
|
3759
|
+
await Promise.all([...hooks].map(async (hook) => {
|
|
3760
|
+
try {
|
|
3761
|
+
await hook();
|
|
3762
|
+
} catch (error) {
|
|
3763
|
+
console.error("[rb/server] shutdown hook error", error);
|
|
3764
|
+
}
|
|
3765
|
+
}));
|
|
3766
|
+
};
|
|
3767
|
+
const bindShutdownSignals = () => {
|
|
3768
|
+
if (signalsBound) return;
|
|
3769
|
+
signalsBound = true;
|
|
3770
|
+
const stop = (signal) => {
|
|
3771
|
+
const timeout = new Promise((resolve) => setTimeout(resolve, SIGNAL_SHUTDOWN_TIMEOUT_MS).unref());
|
|
3772
|
+
void Promise.race([runHooks(), timeout]).finally(() => process.kill(process.pid, signal));
|
|
3773
|
+
};
|
|
3774
|
+
process.once("SIGTERM", stop);
|
|
3775
|
+
process.once("SIGINT", stop);
|
|
3776
|
+
};
|
|
3777
|
+
const onShutdown = (hook) => {
|
|
3778
|
+
hooks.add(hook);
|
|
3779
|
+
bindShutdownSignals();
|
|
3780
|
+
};
|
|
3755
3781
|
let client;
|
|
3756
3782
|
let shutdownHookBound = false;
|
|
3757
3783
|
const resolvePosthogApiKey = (env2) => env2.RB_PUBLIC_POSTHOG_KEY;
|
|
@@ -3791,11 +3817,7 @@ const shutdown = async () => {
|
|
|
3791
3817
|
const ensurePosthogShutdown = () => {
|
|
3792
3818
|
if (shutdownHookBound || !client) return;
|
|
3793
3819
|
shutdownHookBound = true;
|
|
3794
|
-
|
|
3795
|
-
void shutdown();
|
|
3796
|
-
};
|
|
3797
|
-
process.on("SIGTERM", stop);
|
|
3798
|
-
process.on("SIGINT", stop);
|
|
3820
|
+
onShutdown(shutdown);
|
|
3799
3821
|
process.on("beforeExit", shutdown);
|
|
3800
3822
|
};
|
|
3801
3823
|
const POSTHOG_INGEST_TARGET = "https://eu.i.posthog.com";
|
|
@@ -4297,6 +4319,7 @@ const createRedisSessionStore = async (redisUrl) => {
|
|
|
4297
4319
|
});
|
|
4298
4320
|
};
|
|
4299
4321
|
const initServer = async (app, serverEnv) => {
|
|
4322
|
+
bindShutdownSignals();
|
|
4300
4323
|
await initApiClient({
|
|
4301
4324
|
app
|
|
4302
4325
|
});
|
|
@@ -5454,10 +5477,12 @@ const ssrMiddleware = ({
|
|
|
5454
5477
|
}
|
|
5455
5478
|
};
|
|
5456
5479
|
export {
|
|
5480
|
+
bindShutdownSignals,
|
|
5457
5481
|
getDerivedKey,
|
|
5458
5482
|
hashPassword,
|
|
5459
5483
|
hashPasswordForStorage,
|
|
5460
5484
|
initServer,
|
|
5485
|
+
onShutdown,
|
|
5461
5486
|
s as sendEmail,
|
|
5462
5487
|
ssrMiddleware,
|
|
5463
5488
|
verifyPasswordFromStorage
|