-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconstants.ts
More file actions
53 lines (41 loc) · 2.77 KB
/
constants.ts
File metadata and controls
53 lines (41 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { kbToBytes, mbToBytes } from "@lib/utils/fileSize";
// Note 5mb is also defined for Server actions in next.config.ts
export const BODY_SIZE_LIMIT = mbToBytes(5);
export const MAX_FILE_SIZE = 10485760; // 10 MB matches file upload lambda see: generateSignedUrl
export const MAX_RESPONSE_SIZE = kbToBytes(380);
export const MAX_DYNAMIC_ROW_AMOUNT = 50;
export const MAX_CHOICE_AMOUNT = 400;
/*--------------------------------------------*
* Edit lock and timing constants
*--------------------------------------------*/
// Keep the edit lock alive for 6 minutes after the last successful heartbeat so brief stalls
// or delayed requests do not drop ownership while we prefer a quieter, more stable lock.
// This extends the original 5 min to 6 min to provide buffer before 10-min session expires.
export const EDIT_LOCK_TTL_MS = 360_000;
// Only enforce edit locking when more than one assigned person could plausibly edit the form.
export const MIN_ASSIGNED_USERS_FOR_EDIT_LOCK = 2;
// Refresh the owner's lock heartbeat once per minute to reduce network noise; the longer TTL above
// provides enough slack that missing a single heartbeat should not immediately drop the lock.
export const EDIT_LOCK_HEARTBEAT_INTERVAL_MS = 60_000;
// Non-owners check lock status on the same cadence so they can notice ownership changes without
// spamming the server. This can diverge from the owner heartbeat interval later if needed.
// 60 sec
export const EDIT_LOCK_STATUS_POLL_INTERVAL_MS = 60_000;
// Client-side only: throttle local activity updates to at most once per second so rapid input does not
// churn timestamps before the next heartbeat is sent.
export const CLIENT_SIDE_EDIT_LOCK_ACTIVITY_THROTTLE_MS = 1_000;
// After 30 seconds without local interaction, we stop calling the editor actively engaged.
// Status: "Active now" (0-30s) → "Open, no recent activity" (30s-4min)
export const CLIENT_SIDE_EDIT_LOCK_IDLE_MS = 30_000;
// After 4 minutes without interaction, or as soon as the tab is hidden, we treat the editor as away.
// Status changes to: "Away" (4-5min). Provides 1-minute buffer before stale warning appears.
export const CLIENT_SIDE_EDIT_LOCK_AWAY_MS = 240_000;
// Surface a stale connection warning during the last 1 minute of the lock TTL (5-6min).
// Status changes to: "Inactive" + warning banner. Lock expires after 6 minutes total.
export const CLIENT_SIDE_EDIT_LOCK_STALE_THRESHOLD_MS = 60_000;
// Give the current editor a window to flush any dirty draft state before a takeover completes.
// This must be generous enough for Lambda / cold-start environments where the full
// SSE → saveDraft → ack round-trip can take several seconds.
export const EDIT_LOCK_PRE_TAKEOVER_SAVE_WAIT_MS = 5_000;
// Toggle verbose SSE lifecycle logging
export const SHOULD_DEBUG_EDIT_LOCK_SSE = false;