Better OOTB error handling

未关闭
#4,535 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

@imanali2237 已经在做这个了。

开始于 2026年6月30日。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
领域
api, backend

调研方向

首先检查 Hapi.server 选项以及 issue 中描述的 routes.ext.onPreResponse.method() hook,包括当前如何使用 NODE_ENV。确定一种配置结构,以便选择不使用通用错误包装,同时保留安全的默认行为,然后补充对 development 和 production 行为的覆盖,并验证原始错误和 stack trace 的处理。

由索引模型根据 Issue 内容生成。

描述

feature
Runtime

NodeJS

Runtime version

any

Module version

21

What problem are you trying to solve?

Whenever I make a new server and it throws, the error is caught and wrapped into a generic Boom.internal(), with no feedback on the original error or the stack trace. The only way to introspect is to pass routes.ext.onPreResponse.method() to server options.

This is a bit awkward, especially if I'm using the server for non-production cases, tests, or non-critical apps. It would be nice if the option to obfuscate errors was an opt-in / out configuration. I do understand that Hapi is this way in order to be secure by default, I just think it would be helpful

Do you have a new or modified API suggestion to solve the problem?

Perhaps a Hapi.server({ production: true | false }) would suffice? I am currently using NODE_ENV to set the onPreResponse options so I have good feedback at dev time.

主要语言
JavaScript
星标
14.8k
派生
1.4k
平均合并
12 分钟
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

hapijs/hapi 的其他 Issue

查看 hapijs/hapi 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。