Reinstalling an application creates a ghost of its schedules
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- redis, typescript
- Domain
- backend
Research direction
Start with the scheduler configuration in devvit.json, the route shown in index.ts, and the scheduler.listJobs() result. Reproduce the install, uninstall, and reinstall sequence, then trace which scheduled jobs remain and how the Redis-stored widget ID is used. Done means uninstalling removes prior schedules so reinstalling leaves only the current job and does not create duplicate widget updates.
Written by the indexing model from the issue text.
Description
Reddit does not properly clean up apps when they are uninstalled.
You can reproduce this by adding a schedule in your devvit.json. like so:
"scheduler": {
"tasks": {
"daily-guides": {
"endpoint": "/internal/scheduler/daily-guides",
"cron": "* * * * *"
}
}
},
Then, configure a route to handle it:
// index.ts.
router.post("/internal/scheduler/daily-guides", scheduleFunction);
// Maybe in another file...
import { context, reddit, redis } from "@devvit/web/server";
export async function scheduleFunction() {
const widgetId = await redis.get('schedule-key');
if (!widgetId) {
console.info("Widget not found. Creating one.");
const widget = await reddit.addWidget({
subreddit: context.subredditName,
type: "textarea",
shortName: "Countdown",
text: "test",
});
await redis.set('schedule-key', widget.id);
return;
}
await reddit.updateWidget({
subreddit: context.subredditName,
type: "textarea",
id: widgetId,
shortName: "Countdown",
text: "test",
});
}
Then:
- Install the app to a subreddit
- Uninstall it after several minutes
- Install the app to the aforementioned subreddit
After a few minutes after step 3, you'll have a mod log like this:
It looks like the first scheduled has returned and it is updating the widget from the id stored in Redis somehow. It shouldn't know that it is still there. Then, it starts a new schedule from installation, creating a widget since it doesn't know anything about the subreddit which is expected behaviour, stores the widget id in Redis, and proceeds to edit it. This leads to 2 widgets.
If you run await scheduler.listJobs();, only 1 job would be listed–the job you started your application with to log that in the first place–not 2. The other schedule is now a ghost–you cannot find it, you cannot stop it, you cannot uninstall your application as a workaround as demonstrated above... it's totally broken.
I'd appreciate if a lurking administrator can resolve my prior schedules (my application is in the above screenshot)!
- Dominant language
- TypeScript
- Stars
- 210
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from reddit/devvit
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
Similar issues
-
Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenNSW/nsw-srilanka#497 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
0xMiden/bridge-portal#132 ·
-
react-doctor severity:warning tech-debt
Difficulty 1/5 Under an hour Newbie friendliness 88/100
digidem/comapeo-cloud-app#403 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100