Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

pnpm 跑 father dev ⌃+C 退出时报错 #573

Closed
sorrycc opened this issue Jan 31, 2023 · 5 comments
Closed

pnpm 跑 father dev ⌃+C 退出时报错 #573

sorrycc opened this issue Jan 31, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@sorrycc
Copy link
Member

sorrycc commented Jan 31, 2023

是不是给的 signal 不对?其他包管理工具不清楚。

image

@sorrycc sorrycc added the bug Something isn't working label Jan 31, 2023
@xiaohuoni
Copy link
Member

我这里也是 pnpm ,退出正常。
Apple M1 Pro
node v16.13.1

This was referenced Feb 6, 2023
@PeachScript
Copy link
Member

看了下应该是 pnpm 在执行命令的时候,对没有 exitCode 的进程退出也会当做错误退出导致的,用如下方式即可复现:

  1. 新增 a.js
setTimeout(() => {}, 10000);
  1. 加一个脚本
  "scripts": {
    "a": "node a.js"
  }
  1. 执行 pnpm a,并在命令结束前 Ctrl + C 杀掉它,将会获得报错

要处理的话也比较容易,在 a.js 里监听进程退出,手动指定退出码即可:

process.on('SIGINT', () => process.exit(0));

但比较奇怪 pnpm 这个行为,难道所有 script 都需要手动处理 SIGINT 么,对这块没什么经验,大家帮忙看看 @sorrycc @fz6m @xiaohuoni

@fz6m
Copy link
Contributor

fz6m commented Feb 9, 2023

不太了解,也搜不到相关的 issue 和信息,好像社区并不 care 这个事情,手动终止就是没运行完脚本,是错误的结果。

@PeachScript
Copy link
Member

最终方案:给 dev 命令处理 SIGINT,因为 dev 必须要 Ctrl+C 结束;其他命令仍保持原样,不强行改变 exitCode

@PeachScript
Copy link
Member

v4.1.4 已修复

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants