Commit 1e1c591
authored
fix(drizzle): surface connection errors in beginTransaction instead of hanging forever (#16220)
When `beginTransaction` fails to establish a database connection (e.g.
due to network issues or expired AWS IAM tokens), the function hangs
forever instead of throwing an error.
This happens because `drizzle.transaction()` rejects when the connection
fails, but the old `.catch(() => { // swallow })` silently ate the
error. Since the transaction callback never ran, `transactionReady()`
was never called, leaving the outer `await` permanently suspended.
Callers never receive an error and the operation never completes.
The fix replaces the swallowed `.catch` with one that rejects the outer
promise, so the existing `try/catch` block can log the real error and
re-throw it to callers.
## What happened in practice
In practice, this issue resulted in the job queue to randomly stop
processing jobs, if a previous cron hangs during `beginTransaction`. The
only way to get it to start processing jobs again was to restart the
node process.
---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
- https://app.asana.com/0/0/12139838362660371 parent c5e0e02 commit 1e1c591
File tree
2 files changed
+51
-3
lines changed- packages/drizzle/src/transactions
- test/database
2 files changed
+51
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
48 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
53 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2321 | 2321 | | |
2322 | 2322 | | |
2323 | 2323 | | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
2324 | 2367 | | |
2325 | 2368 | | |
2326 | 2369 | | |
| |||
0 commit comments