Commit 7ae7cfd
fix(cf-function): guard against null metadata to prevent 502s
When the KV store returns null/undefined for the metadata key — which
can happen transiently during deployment as the KV entry propagates to
edge nodes — routeSite throws an uncaught TypeError accessing
metadata.base, causing CloudFront to return a 502.
This is most visible when errorPage is configured, because that disables
the function-level custom404 fallback in favour of distribution-level
customErrorResponses. The 502 manifests inconsistently because only
some edge nodes are affected during the propagation window.
The fix fails open: if metadata is unavailable, pass the request through
to the default origin unchanged rather than crashing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 3b0c5c4 commit 7ae7cfd
2 files changed
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
943 | 943 | | |
944 | 944 | | |
945 | 945 | | |
| 946 | + | |
946 | 947 | | |
947 | 948 | | |
948 | 949 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1129 | 1129 | | |
1130 | 1130 | | |
1131 | 1131 | | |
| 1132 | + | |
1132 | 1133 | | |
1133 | 1134 | | |
1134 | 1135 | | |
| |||
0 commit comments