Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Use of error in nodecg-io-core where warning is appropriate #365

Closed
@ExtremTechniker

Description

@ExtremTechniker

Description

nodecg-io-core logs out an error when config is already deencrypted.
Fix change the log if it is a config already decrypted error from error to warning

How to reproduce

  • Add to cfg/nodecg-io-core.json the config to auto login like described in the documentation.
  • Open localhost:9090, login and restart nodecg
  • Now the browser is faster to decrypt the config before nodecg-io-core can auto login,
    therefore nodecg-io-core is logging an error.
error: [nodecg-io-core] Failed to automatically login: Config has already been decrypted and loaded.

References

private setupAutomaticLogin(password: string): void {
// We need to do the login after all bundles have been loaded because when loading these might add bundle dependencies
// or even register services which we need to load nodecg-io.
// There is no official way to wait for nodecg to be done loading so we use more or less a hack to find that out:
// When we declare the replicant here we will trigger a change event with a empty array.
// Once nodecg is done loading all bundles it'll assign a array of bundles that were loaded to this replicant
// So if we want to wait for nodecg to be loaded we can watch for changes on this replicant and
// if we get a non-empty array it means that nodecg has finished loading.
this.nodecg.Replicant<unknown[]>("bundles", "nodecg").on("change", async (bundles) => {
if (bundles.length > 0) {
try {
this.nodecg.log.info("Attempting to automatically login...");
const loadResult = await this.load(password);
if (!loadResult.failed) {
this.nodecg.log.info("Automatic login successful.");
} else {
throw loadResult.errorMessage;
}
} catch (err) {
this.nodecg.log.error(`Failed to automatically login: ${err}`);
}
}
});
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestframeworkRequires changes to the frameworkminorQuick to implement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions