# SnapStart 钩子超时：运行时钩子在 10 秒内未完成。

- **ID:** `aws/lambda-snapstart-hook-timeout`
- **领域:** aws
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

Lambda SnapStart 初始化钩子（例如 Java）在快照创建期间超过了 10 秒限制。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| java-21 | active | — | — |
| snapstart-1.0 | active | — | — |
| aws-lambda-java-core-1.2.3 | active | — | — |

## 解决方案

1. ```
   优化 `CRaC` 或 `beforeCheckpoint` 钩子中的初始化代码：将重负载设置（如数据库连接池）移至检查点后的延迟初始化。
   ```
2. ```
   使用更小的运行时或减少类路径扫描：在 Spring Boot 中设置 `spring.context.initializer.exclude` 以跳过慢速 bean。
   ```

## 无效尝试

- **** — Increasing Lambda timeout setting doesn't affect SnapStart hook timeout; the 10-second limit is fixed. (100% 失败率)
- **** — Disabling SnapStart entirely removes the performance benefit and doesn't fix the root cause. (50% 失败率)
