Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Registered functions running immediately

Đang mở
#1 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript
Lĩnh vực
backend, databases

Hướng nghiên cứu

Start with the shown tasks entry point and trace Task.registerHandler, Task.startPolling, and Task.findOneAndUpdate in the task package. Reproduce the restart and noon executions, then determine which scheduling step triggers them and document or correct the behavior with a regression test if the repository provides one.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

help wanted

I have a discord bot where one of the features is that on September 21st, it will send the youtube link the song "September". For some reason, these past two days it was running the task at noon. When trying to debug, it would also run on application restart. I'm wondering if there is an explanation to this behavior as I don't see why the code in its current state is allowing this behavior.

const db = require('../db');
const initTasks = require('@mongoosejs/task');

module.exports = async function tasks(bot) {
  try {
    const conn = await db().asPromise();
    const setup = { db: conn }
    initTasks(null, setup.db);
    const { Task } = setup.db.models;

    Task.registerHandler('september', function quirkMessage() {
      return september(bot);
    });

    await Task.startPolling();

    await Task.findOneAndUpdate({ name: 'september', status: 'pending' }, { scheduledAt: earthWindAndFire(), repeatAfterMS: millisecondsInYear }, { upsert: true, returnDocument: 'after' });

  } catch(error) {
    console.log('something went wrong registering all the handlers', error);
  }
}

function earthWindAndFire() {
  const date = new Date()
  const year = date.getFullYear();
  const septemberTwentyFirst = new Date(year, 8, 21, 19);
  return septemberTwentyFirst;
}

Ngôn ngữ chính
JavaScript
Star
4
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.