Repository navigation
Commit f831f9a
authored
fix: prevent submission endpoint hang on Cloudflare Workers (#141)
Replace the interactive transaction in formData.setFormData with a single atomic ctx.db.batch(). The interactive transaction issued four sequential network round-trips (BEGIN/INSERT/UPDATE/COMMIT) that held the libSQL write lock for their whole duration; under concurrent submissions they serialized on the lock and blew the Worker execution budget, so workerd canceled the request as hung. batch() runs both writes in one round-trip inside an implicit backend transaction, preserving all-or-nothing atomicity (the FK-failure rollback test stays green).
Defer the notification email with Next's after() instead of a floating promise. I/O started by a promise that outlives the response is invalid on Workers, so notification emails silently failed; after() runs it in a valid post-response context (OpenNext maps it to waitUntil) and a .catch() keeps a failed email from escalating to a request exception.1 parent cd56a6f commit f831f9a
2 files changed
Lines changed: 13 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
146 | 150 | | |
147 | 151 | | |
148 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
| 123 | + | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
| 131 | + | |
| 132 | + | |
134 | 133 | | |
135 | 134 | | |
136 | 135 | | |
137 | 136 | | |
138 | 137 | | |
139 | | - | |
| 138 | + | |
| 139 | + | |
140 | 140 | | |
141 | | - | |
142 | | - | |
| 141 | + | |
143 | 142 | | |
144 | 143 | | |
145 | 144 | | |
| |||
0 commit comments