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] failed to initialize unidoc: license key already set #539

Closed
amir-faliam opened this issue Nov 14, 2023 · 4 comments
Closed

[BUG] failed to initialize unidoc: license key already set #539

amir-faliam opened this issue Nov 14, 2023 · 4 comments

Comments

@amir-faliam
Copy link

Description

We are using unidoc in one of our lambdas to generate PDFs. Below is what our initialization code looks like:

// This function is used to initialize the unidoc license
var unidocInit = false

func initUniDoc(ctx context.Context) error {
	if unidocInit {
		return nil
	}
	secrets := common.GetSecrets(ctx)
	// This can only get called once or it'll error out, so we need to make sure it's only called once
	err := license.SetMeteredKey(*secrets.UniDocSecret)
	if err != nil {
		return err
	}
	unidocInit = true
	return nil
}

Have verified that there is no way for this init call to be made concurrently, yet somehow we get the license key already set error.

Expected Behavior

license key already set never be thrown

Actual Behavior

This issue is not deterministically reproducible, we have noticed it has happened a total of 3 times on our lambdas based on the initialization code above

Attachments

N/A

Copy link

Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/

@sampila
Copy link
Collaborator

sampila commented Nov 15, 2023

Hi @amir-faliam

You only need to init the license once, so no need to do license initialization every time you are using the library.
You only need to set the license initialization on each time your app starting, as long as your application is still running, the license will still be set.

@amir-faliam
Copy link
Author

Sorry jumped the gun here! There were some incorrect assumptions we were making on our side! All good here

@sampila
Copy link
Collaborator

sampila commented Nov 15, 2023

@amir-faliam glad to hear that the problem is solved

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

No branches or pull requests

2 participants