Scheduler jobs register but never execute; listJobs() returns empty immediately after runJob() (reproduces on published unlisted app)

Abierto
#259 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
node.js, typescript
Área
backend

Línea de trabajo

No source file or test is named. Start by tracing the Devvit.addSchedulerJob registration and the context.scheduler.runJob() and listJobs() entry points using the supplied reproduction; compare one-shot and cron scheduling. Done means a returned job appears in listJobs() and its onRun handler executes for uploaded and published-unlisted apps.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

context.scheduler.runJob() returns a valid job UUID, but the job never executes. context.scheduler.listJobs() returns an empty array immediately after runJob() returns. This affects both recurring cron jobs and one-shot runAt jobs. Menu item handlers and AppInstall / AppUpgrade triggers fire correctly on the same app, so the issue is isolated to the scheduler itself.

The behavior reproduces on both an uploaded (private) app and a published (unlisted) app, ruling out publish status as a factor.

Environment

  • App slug: rapids-match-bot
  • App URL: https://developers.reddit.com/apps/rapids-match-bot
  • Devvit CLI: 0.12.13
  • @devvit/public-api: latest at time of build
  • App versions tested: 0.0.3 through 0.0.14 (all exhibit the bug)
  • Publish status when bug reproduces: both uploaded (v0.0.13) and published unlisted (v0.0.14)
  • Test subreddit: r/rapids_match_bot_dev (private dev sub, mod-installed)
  • Node: 22

Steps to reproduce

  1. Register a scheduler job at the top level:
   Devvit.addSchedulerJob({
     name: JOB_CHECK_MATCHES,
     onRun: checkMatchesJob,
   });
  1. In an AppInstall / AppUpgrade trigger, first iterate listJobs() and cancelJob() each (per #239 mitigation), then call:
   const jobId = await context.scheduler.runJob({
     name: JOB_CHECK_MATCHES,
     runAt: new Date(Date.now() + 60_000),
   });
   await context.redis.set('cronJobId', jobId);
  1. Note that jobId is a valid UUID and is persisted to Redis successfully.
  2. Immediately call context.scheduler.listJobs() from a moderator menu item.

Observed behavior

  • runJob() returns a valid UUID (e.g. 9225215c-f9df-4304-8069-4bf8c4f1da2c).
  • listJobs() returns [].
  • The registered job never executes. No onRun invocation. No log output. No side effects (no Reddit post submitted from inside the handler, even when the handler is reduced to a single submitPost call as a smoke test).
  • This is true for both cron recurring jobs and runAt one-shot jobs.
  • This is true on the uploaded version (v0.0.13) and on the published unlisted version (v0.0.14).

Expected behavior

  • runJob() returns a UUID.
  • listJobs() returns a non-empty array containing that UUID.
  • The job's onRun handler executes at the scheduled time.

Diagnostic evidence

A moderator menu item posts a self-post showing the stored job ID and the result of listJobs():

Scheduler Status — 0 active job(s)
Stored cronJobId: 9225215c-f9df-4304-8069-4bf8c4f1da2c
Active jobs: No active jobs found.

The stored ID changes across upgrades (v0.0.13 stored 085a820b-da46-4235-bf05-febac368531d; v0.0.14 stored 9225215c-f9df-4304-8069-4bf8c4f1da2c), confirming the AppUpgrade trigger is firing and runJob() is being called and returning successfully each time. The job simply never appears in listJobs() and never executes.

What I've already tried (ruled out as causes)

  • Cron expression syntax. Failure reproduces with runAt: new Date(...) one-shot jobs, not just cron.
  • runAt vs when parameter. Confirmed against the installed @devvit/public-api types that runAt is the correct parameter; when produces a TS2353 type error. Both forms fail at runtime regardless.
  • Ghost schedules (#239). Cleanup loop iterating listJobs() and cancelJob() runs at the top of every AppInstall / AppUpgrade trigger before any new runJob() calls. No effect.
  • Self-rescheduling one-shot pattern. Replaced cron with a runAt job that re-schedules itself at the end of onRun. Same failure: the first job never fires, so the chain never starts.
  • Trigger registration. AppInstall and AppUpgrade triggers are confirmed firing (Redis writes happen, console logs appear in devvit logs).
  • Menu items. Menu item onPress handlers execute correctly, including submitPost calls. The app is fully functional except for scheduled execution.
  • App publish status. Bug reproduces on both uploaded and published-unlisted versions.

Question

Is there a known issue with scheduler execution on apps installed in private subreddits, or some other configuration gate I'm missing? Given that runJob() returns successfully but listJobs() shows nothing, it looks like the scheduler is silently dropping registered jobs. Any guidance on how to debug further from the application side would be appreciated.

Related

  • #239 (ghost schedules from reinstallation; mitigation applied, does not resolve this)
Lenguaje dominante
TypeScript
Estrellas
210
Forks
88
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de reddit/devvit

Todos los issues de reddit/devvit

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.