Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when calling Devvit.configure() more than once #132

Open
Yay295 opened this issue Dec 16, 2024 · 1 comment
Open

Bug when calling Devvit.configure() more than once #132

Yay295 opened this issue Dec 16, 2024 · 1 comment

Comments

@Yay295
Copy link

Yay295 commented Dec 16, 2024

static configure(config: Configuration): void {
this.#config = { ...this.#config, ...config };
if (pluginIsEnabled(config.http)) {
this.use(protos.HTTPDefinition);
}
// We're now defaulting this to on.
const redisNotSpecified = config.redis === undefined;
if (redisNotSpecified || pluginIsEnabled(config.kvStore) || pluginIsEnabled(config.redis)) {
this.use(protos.KVStoreDefinition);
this.use(protos.RedisAPIDefinition);
}
if (pluginIsEnabled(config.media)) {
this.use(protos.MediaServiceDefinition);
}
if (pluginIsEnabled(config.modLog)) {
this.use(protos.ModlogDefinition);
}
if (pluginIsEnabled(config.redditAPI)) {
// Loading all Reddit API plugins for now.
// In the future we can split this by oauth scope or section.
this.use(protos.FlairDefinition);
this.use(protos.GraphQLDefinition);
this.use(protos.LinksAndCommentsDefinition);
this.use(protos.ListingsDefinition);
this.use(protos.ModerationDefinition);
this.use(protos.ModNoteDefinition);
this.use(protos.NewModmailDefinition);
this.use(protos.PrivateMessagesDefinition);
this.use(protos.SubredditsDefinition);
this.use(protos.UsersDefinition);
this.use(protos.WidgetsDefinition);
this.use(protos.WikiDefinition);
}
if (pluginIsEnabled(config.realtime)) {
this.use(protos.RealtimeDefinition);
}
}

If HTTP is enabled in the first call, then config will have http set to true. If you then try to disable HTTP with Devvit.configure({ http: false }), http will be set to false in config, but the plugin will not be un-this.use()d. It looks like the Reddit API is the only plugin that checks the config value instead of the existence of the plugin.

if (!pluginIsEnabled(this.#config.redditAPI)) {

const realtime = this.#pluginClients[protos.RealtimeDefinition.fullName];
if (!realtime) {

@Yay295
Copy link
Author

Yay295 commented Dec 17, 2024

Personally I don't think it should be possible to disable a plugin after it's been enabled. It could create hard to debug issues where you think you've enabled a plugin in one place but it's been disabled somewhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant