You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/backend/.env
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,13 @@ STACK_EMAILABLE_API_KEY=# for Emailable email validation, see https://emailable.
44
44
45
45
STACK_DEFAULT_EMAIL_CAPACITY_PER_HOUR=# the number of emails a new project can send. Defaults to 200
46
46
47
+
# Email branching configuration
48
+
# If you have multiple deployments of compute accessing the same DB or multiple copies of a DBs connected to compute (as
49
+
# you would in preview/branching environments), you may want to either disable the auto-triggered email queue steps
50
+
# (those that trigger whenever an email is sent, besides the cron job), or disable email sending as a whole.
51
+
STACK_EMAIL_BRANCHING_DISABLE_QUEUE_AUTO_TRIGGER=# set to 'true' to disable the automatic triggering of the email queue step. the cron job must call /email-queue-step to run the queue step. Most useful on production domains where you know the cron job will run on the correct deployment and you don't need the auto-trigger (which may be on the wrong deployment)
52
+
STACK_EMAIL_BRANCHING_DISABLE_QUEUE_SENDING=# set to 'true' to throw an error instead of sending emails in the email queue step. Most useful on development branches that have a copy of the production DB, but should not send any emails (as otherwise some emails could be sent twice)
53
+
47
54
48
55
# Database
49
56
# For local development: `docker run -it --rm -e POSTGRES_PASSWORD=password -p "8128:5432" postgres`
@@ -75,8 +82,7 @@ STACK_QSTASH_TOKEN=
75
82
STACK_QSTASH_CURRENT_SIGNING_KEY=
76
83
STACK_QSTASH_NEXT_SIGNING_KEY=
77
84
78
-
79
-
# Misc, optional
85
+
# Misc
80
86
STACK_ACCESS_TOKEN_EXPIRATION_TIME=# enter the expiration time for the access token here. Optional, don't specify it for default value
81
87
STACK_SETUP_ADMIN_GITHUB_ID=# enter the account ID of the admin user here, and after running the seed script they will be able to access the internal project in the Stack dashboard. Optional, don't specify it for default value
82
88
OTEL_EXPORTER_OTLP_ENDPOINT=# enter the OpenTelemetry endpoint here. Optional, default is `http://localhost:8131`
@@ -139,7 +140,7 @@ async function updateLastExecutionTime(): Promise<number> {
139
140
-- Concurrent insert race: another worker just inserted, skip this run
140
141
WHEN NOT EXISTS (SELECT 1 FROM result) THEN 0.0
141
142
-- First run (inserted new row), use reasonable default delta
142
-
WHEN (SELECT previous_timestamp FROM result) IS NULL THEN 60.0
143
+
WHEN (SELECT previous_timestamp FROM result) IS NULL THEN 20.0
143
144
-- Normal update case: compute actual delta
144
145
ELSE EXTRACT(EPOCH FROM
145
146
(SELECT new_timestamp FROM result) -
@@ -150,9 +151,14 @@ async function updateLastExecutionTime(): Promise<number> {
150
151
151
152
if(delta<0){
152
153
// TODO: why does this happen, actually? investigate.
154
+
console.warn("Email queue step delta is negative. Not sure why it happened. Ignoring the delta. TODO investigate",{ delta });
153
155
return0;
154
156
}
155
157
158
+
if(delta>30){
159
+
captureError("email-queue-step-delta-too-large",newStackAssertionError(`Email queue step delta is too large: ${delta}. Either the previous step took too long, or something is wrong.`));
160
+
}
161
+
156
162
returndelta;
157
163
}
158
164
@@ -491,15 +497,17 @@ async function processSingleEmail(context: TenancyProcessingContext, row: EmailO
0 commit comments