Skip to content

Commit 14a7e6e

Browse files
haowu77claude
andcommitted
Add Troubleshooting section for UserPromptSubmit hook timeout error
Document the known hook timeout issue when NER engine takes >30s on first run. Recommend increasing timeout to 60000ms or switching to regex engine for faster processing. Added to both EN and ZH READMEs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5354f25 commit 14a7e6e

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,53 @@ privacy-mask follows the [agentskills.io](https://agentskills.io) SKILL.md stand
9999
100100
---
101101

102+
## Troubleshooting
103+
104+
### `UserPromptSubmit hook error`
105+
106+
If you see this error when sending images in Claude Code, it means the privacy-mask hook **timed out** before finishing. This is a known issue — the NER engine needs time to load the GLiNER model (~170MB) on first run. The image is usually still masked successfully despite the error message.
107+
108+
**Fix: increase the hook timeout** in `~/.claude/settings.json`:
109+
110+
```json
111+
{
112+
"hooks": {
113+
"UserPromptSubmit": [
114+
{
115+
"matcher": "",
116+
"hooks": [
117+
{
118+
"type": "command",
119+
"command": "bash ~/.claude/hooks/privacy-mask.sh",
120+
"timeout": 60000
121+
}
122+
]
123+
}
124+
]
125+
}
126+
}
127+
```
128+
129+
The default timeout is 30000ms (30s). We recommend **60000ms (60s)** for NER engine, or 30000ms if you only use the regex engine.
130+
131+
**Alternative: switch to regex engine** for faster processing (~2-5s vs ~20-30s):
132+
133+
```bash
134+
# Edit ~/.claude/hooks/privacy-mask.sh or config.json
135+
# Set detection engine to regex
136+
privacy-mask mask screenshot.png --detection-engine regex
137+
```
138+
139+
To change the default engine, edit `mask_engine/data/config.json`:
140+
141+
```json
142+
{
143+
"detection": { "engine": "regex" }
144+
}
145+
```
146+
147+
---
148+
102149
## Detection Engines
103150

104151
privacy-mask supports two detection engines, switchable via config or CLI:

README.zh.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,45 @@ privacy-mask 遵循 [agentskills.io](https://agentskills.io) SKILL.md 标准,
9696
9797
---
9898

99+
## 常见问题
100+
101+
### `UserPromptSubmit hook error`
102+
103+
在 Claude Code 中发送图片时看到此错误,表示 privacy-mask hook **处理超时**。这是已知问题——NER 引擎首次运行需要加载 GLiNER 模型(约 170MB)。尽管显示错误,图片通常仍然成功遮蔽。
104+
105+
**解决方法:增加 hook 超时时间**,编辑 `~/.claude/settings.json`
106+
107+
```json
108+
{
109+
"hooks": {
110+
"UserPromptSubmit": [
111+
{
112+
"matcher": "",
113+
"hooks": [
114+
{
115+
"type": "command",
116+
"command": "bash ~/.claude/hooks/privacy-mask.sh",
117+
"timeout": 60000
118+
}
119+
]
120+
}
121+
]
122+
}
123+
}
124+
```
125+
126+
默认超时 30000ms(30 秒),NER 引擎建议设为 **60000ms(60 秒)**。如果只用 regex 引擎,30000ms 即可。
127+
128+
**替代方案:切换到 regex 引擎**(处理速度 2-5 秒 vs NER 的 20-30 秒):
129+
130+
```json
131+
{
132+
"detection": { "engine": "regex" }
133+
}
134+
```
135+
136+
---
137+
99138
## 检测能力
100139

101140
**47 条正则规则**,覆盖 **15+ 国家**

0 commit comments

Comments
 (0)