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

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

Closed
ExtremTechniker opened this issue Dec 16, 2021 · 0 comments · Fixed by #385
Closed

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

ExtremTechniker opened this issue Dec 16, 2021 · 0 comments · Fixed by #385
Assignees
Labels
enhancement New feature or request framework Requires changes to the framework minor Quick to implement
Milestone

Comments

@ExtremTechniker
Copy link
Contributor

ExtremTechniker commented Dec 16, 2021

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}`);
}
}
});
}

@ExtremTechniker ExtremTechniker added the enhancement New feature or request label Dec 16, 2021
@hlxid hlxid added framework Requires changes to the framework minor Quick to implement labels Dec 16, 2021
@hlxid hlxid added this to the v0.3.0 milestone Dec 17, 2021
@hlxid hlxid self-assigned this Dec 22, 2021
hlxid added a commit that referenced this issue Dec 22, 2021
…ady loaded

Fixes #365.
If automatic login fails and nodecg-io is not loaded afterwards this will still display a error. This happens when e.g. the password set in the automatic login config is wrong.
However if automatic login fails and nodecg-io is loaded afterwards just a warning will be logged with this PR. This is the case when the dashboard reconnects after a restart and loggs back in.
hlxid added a commit that referenced this issue Dec 25, 2021
…ady loaded (#385)

Fixes #365.
If automatic login fails and nodecg-io is not loaded afterwards this will still display a error. This happens when e.g. the password set in the automatic login config is wrong.
However if automatic login fails and nodecg-io is loaded afterwards just a warning will be logged with this PR. This is the case when the dashboard reconnects after a restart and loggs back in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request framework Requires changes to the framework minor Quick to implement
Projects
None yet
2 participants