Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Graceful exit has not taken effect

未关闭
#112 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞

调研方向

使用 router.js 和 index.js 复现该问题:运行 node index.js,启动持续三秒的 /test 请求,并向 htop 中识别出的进程发送 SIGTERM。首先跟踪 egg-cluster 的 startCluster 入口点及其信号处理。完成的标准是,在 Egg 服务器关闭之前,正在传输中的请求收到成功响应。

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

描述

Version:
system: macOS 14.4.1
node: 20.12.2
"egg": "^3.17.5",
"egg-cluster": "^2.2.1",

Minimal Code Example:

npx egg-init --type simple

// router.js
module.exports = app => {
  const { router, controller } = app;
  router.get('/', controller.home.index);

// add a router has a 3 seconds aysnc job
  router.get("/test", async (ctx) => {
    await new Promise((resolve) => {
      setTimeout(() => {
        resolve(1);
      }, 3000);
  });
  ctx.body = "test";
})

};

// index.js
const startCluster = require('egg-cluster').startCluster;

startCluster({
  baseDir: __dirname,
  workers: 2,
  port: 7001,
});
  1. start command: node index.js
  2. find node index.js pid in htop
  3. curl -v http://127.0.0.1:7001/api/v1/test
  4. send SIGTERM signal to pid filter in step 2

Expected: The request in step 3 has a successful response, EGG server closes after handling in transit connection.

Actually: the connection is closed immediately after the SIGTERM signal send.

主要语言
JavaScript
星标
222
派生
52
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

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