devvit icon indicating copy to clipboard operation
devvit copied to clipboard

EventSource enum missing in actual runtime

Open PitchforkAssistant opened this issue 1 year ago • 0 comments

The PostDelete event contains a source property of the type EventSource. It's exported and available to import from @devvit/protos, but the runtime doesn't seem to match that.

The following code is valid, builds, and uploads:

import {EventSource, PostDelete} from "@devvit/protos";
import {TriggerContext} from "@devvit/public-api";

export async function onPostDelete (event: PostDelete, context: TriggerContext) {
    if (event.source !== EventSource.USER) {
        return;
    }
    // handle user deletion...
    console.log(`Processing user deletion of ${event.postId}`);
}

However it fails when actually running on Devvit with the error: TypeError: Cannot read properties of undefined (reading 'USER')

This wasn't always the case and is affecting apps that were previously referencing the enum without issues. I am not sure when it went missing, but it was still there a few months ago.

PitchforkAssistant avatar Sep 26 '24 15:09 PitchforkAssistant