unidoc/unipdf

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

amir-faliam opened this issue · 4 comments

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

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/

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.

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

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