Commit 10a8f0f
authored
fix(next): unhandled error in renderListView server function when no user present (#14878)
Previously, the following error may be thrown when no `user` is present
on the `req`:
```ts
TypeError: Cannot read properties of null (reading 'collection')
at renderListHandler (packages/next/src/views/List/handleServerFunction.tsx:66:28)
at async Server.<anonymous> (test/dev.ts:129:5)
64 | {
65 | 'user.relationTo': {
> 66 | equals: user.collection,
| ^
67 | },
68 | },
69 | { {
digest: '4059983158'
}
POST /admin/collections/with-list-drawer 500 in 164ms (compile: 2ms, render: 162ms)
```
I'm seeing it thrown a lot in our test suites, likely because it's
logging out the user while a previous request is still going on.
This PR explicitly throws an `UnauthorizedError` before the server
function tries to access properties on the `user` object.1 parent c9a8aa0 commit 10a8f0f
1 file changed
+11
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
7 | 13 | | |
8 | 14 | | |
9 | 15 | | |
| |||
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
| |||
0 commit comments