`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errors
@cobyfrombrooklyn-bot 已经在做这个了。
开始于 2026年2月25日。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- javascript, node.js
调研方向
从 issue 中指出的 sign.js 第 217-225 行开始,并使用 jsonwebtoken 9.0.2 运行 a.mjs 复现。跟踪 issuer 冲突时的 callback 行为,并验证报告的错误只会导致调用一次 callback,而不是两次。
由索引模型根据 Issue 内容生成。
描述
Description
The callback to jwt.sign() is executed twice when there is an error Bad "options.issuer" option. The payload already has an "iss" property. I would expect the callback to only be executed once.
Reproduction
// a.mjs
import jwt from "jsonwebtoken";
jwt.sign(
{
iss: "bar",
iat: 1757476476,
},
"secret",
{
algorithm: "HS256",
issuer: "foo",
},
(err, asyncSigned) => {
console.log("callback called:", asyncSigned ?? err?.message);
},
);
$> npm init -y && npm add jsonwebtoken
$> node a.mjs
callback called: Bad "options.issuer" option. The payload already has an "iss" property.
callback called: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYXIiLCJpYXQiOjE3NTc0NzY0NzZ9.TkSecbZDocHnjwnuDhQRXNvRkxsERNGBkRc6P0wHlNY
Notice that "callback called" is printed twice, while I would expect it to be printed only once.
Environment
jsonwebtoken 9.0.2 on Darwin 24.6.0 arm64 arm
Other information
It looks like the error is here:
Typically, return failure() throws which exits the forEach and the function. But when a callback is provided, it only returns from the forEach. The rest of the keys are checked and the rest of the function still runs.
- 主要语言
- JavaScript
- 星标
- 18.2k
- 派生
- 1.3k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
auth0/node-jsonwebtoken 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
auth0/node-jsonwebtoken#1042 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 45/100
auth0/node-jsonwebtoken#1048 ·
-
verify() resolves a string secret by attempting createPublicKey() first, costing 4x-52x on the HS* path可能已有人在做 @Hashim1999164 于 23 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 65/100
auth0/node-jsonwebtoken#1046 ·
-
难度 5/5 一周以上 新手友好度 10/100
auth0/node-jsonwebtoken#1034 ·
-
jwt.verify accepts tokens with unrecognized `crit` header extensions (RFC 7515 §4.1.11)可能已有人在做 @ArockiaRajamanickam 于 70 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 48/100
auth0/node-jsonwebtoken#1032 ·
查看 auth0/node-jsonwebtoken 的全部 Issue
相似的 Issue
-
bug MVP
难度 2/5 1-3 小时 新手友好度 68/100
saayam-for-all/webapp#1911 ·
维护者通常 1 天内回复
-
[Focus] Accessibility (a11y) [Package] Grid [Type] Bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
Cancelled query leaves stale row index; next query on the connection returns leading empty slots可能已有人在做 @pislm 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 7 天内回复
-
Harden bayesian-waves-bg.js: add prefers-reduced-motion, pointer-events guard, and hidden-tab pause未关闭
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 1/5 1 小时以内 新手友好度 90/100
njitacm/njit-acm-website#109 ·