Commit a3e582d
fix(driver-utils): prevent unhandled rejection in prefetch fire-and-forget calls
Fix three fire-and-forget patterns that cause unhandled rejections:
1. getSnapshotTree(): `void p.then(...)` creates a derived promise that
rejects when p rejects. Added `.catch()` to the promise chain.
2. prefetchTree()/prefetchTreeCore(): `void this.cachedRead(blob)` discards
the async function's returned promise. Since cachedRead is async, it
returns a separate promise chain from the inner prefetchedBlobPFromStorage.
The existing `.catch()` inside cachedRead only handles the inner promise,
not the async function's returned promise. Changed to
`this.cachedRead(blob).catch(() => {})`.
The root cause: attaching `.catch()` to a promise P only prevents unhandled
rejection for P's chain. When an async function returns P, the function's
returned promise is a DIFFERENT chain that also rejects - and needs its own
`.catch()` handler.
This is a follow-up to PR #26151 which only fixed the inner promise in
cachedRead but didn't fix the callers' fire-and-forget patterns.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: anthony-murphy <anthony.murphy@microsoft.com>1 parent 6b203f0 commit a3e582d
File tree
2 files changed
+48
-11
lines changed- packages/loader/driver-utils/src
- test
2 files changed
+48
-11
lines changedLines changed: 20 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
| |||
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
84 | | - | |
85 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
89 | 97 | | |
90 | 98 | | |
91 | 99 | | |
92 | 100 | | |
93 | | - | |
94 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
95 | 104 | | |
96 | 105 | | |
97 | 106 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
160 | 165 | | |
161 | 166 | | |
162 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
163 | 191 | | |
0 commit comments