Upgrade to v4 using le-store-s3 #49

Closed
opened 2020-06-09 19:15:33 +00:00 by Ghost · 2 comments

Background:

Hi, I'm new to Javascript and Git, so please forgive my ignorance and/or lack of decorum. I am trying to upgrade an exsting client of greenlock v2 to use greenlock v4. I hope this is the right place for filing "issues" and asking questions, since I don't see sufficient granularity of details in the existing documentation to cover my use case. I am using https://www.npmjs.com/package/le-store-s3 as the store.

Version:

Greenlock 4.0.4

Problem:

When invoking get() the following fatal error occurs:

17:52:48.789Z ERROR main: Fatal error during greenlock init:
17:52:48.789Z ERROR main: Converting circular structure to JSON

Cause:

I see manage.defaults() is invoked twice when initializing the greenlock manager:

During the first invocation, the greenlock manager acts as a "getter" and returns the config here

During the second invocation, the greenlock manager acts as a "setter" and attempts to save the configured defaults here

During the config "save", JSON.stringify throws the exception "TypeError: Converting circular structure to JSON at JSON.stringify (anonymous) at Object.manage._save" when creating the data object

I am using the le-store-s3 create() function to create the le store, then I used a recursive function to print out these "cyclic references" within the le store object as follows:

CIRCULAR: obj.s3.config.logger.streams.0.stream.stream.stream._handle.owner = obj.s3.config.logger.streams.0.stream.stream.stream = [object Object]
CIRCULAR: obj.s3.config.logger.streams.1.stream.stream.stream.client._handle.owner = obj.s3.config.logger.streams.1.stream.stream.stream.client = [object Object]
CIRCULAR: obj.keypairs.store = obj = [object Object]
CIRCULAR: obj.configs.store = obj = [object Object]
CIRCULAR: obj.accounts.store = obj = [object Object]
CIRCULAR: obj.accounts.keypairs.store = obj = [object Object]
CIRCULAR: obj.certificates.store = obj = [object Object]
CIRCULAR: obj.certificates.keypairs.store = obj = [object Object]
CIRCULAR: obj.certificates.configs.store = obj = [object Object]

The le store and the s3 logger stream handler owner appear to be "cyclic references" which cause JSON.stringify to throw.

Summary:

I'd greatly appreciate feedback and suggestions to help me help myself. I'm not sure if there's a "proper" fix for this or if I should just start hacking away? I'm assuming I'm not the first person attempting to upgrade to greenlock v4 using AWS S3 as the store, so hopefully this is something basic which I'm ignorant and unaware of?

**Background:** Hi, I'm new to Javascript and Git, so please forgive my ignorance and/or lack of decorum. I am trying to upgrade an exsting client of greenlock v2 to use greenlock v4. I hope this is the right place for filing "issues" and asking questions, since I don't see sufficient granularity of details in the existing documentation to cover my use case. I am using https://www.npmjs.com/package/le-store-s3 as the store. **Version:** Greenlock 4.0.4 **Problem:** When invoking `get()` the following fatal error occurs: ``` 17:52:48.789Z ERROR main: Fatal error during greenlock init: 17:52:48.789Z ERROR main: Converting circular structure to JSON ``` **Cause:** I see `manage.defaults()` is invoked twice when [initializing the greenlock manager](https://git.coolaj86.com/coolaj86/greenlock.js/src/branch/master/greenlock.js#L123): * First invocation from [mergeDefaults(MCONF, gconf);](https://git.coolaj86.com/coolaj86/greenlock.js/src/branch/master/greenlock.js#L129) * Second invocation from [return greenlock.manager._defaults(MCONF);](https://git.coolaj86.com/coolaj86/greenlock.js/src/branch/master/greenlock.js#L136) During the first invocation, [the greenlock manager acts as a "getter" and returns the config here](https://git.coolaj86.com/coolaj86/greenlock-manager-fs.js/src/branch/master/manager.js#L54) During the second invocation, [the greenlock manager acts as a "setter" and attempts to save the configured defaults here](https://git.coolaj86.com/coolaj86/greenlock-manager-fs.js/src/branch/master/manager.js#L64) During the config "save", [JSON.stringify throws the exception "TypeError: Converting circular structure to JSON at JSON.stringify (anonymous) at Object.manage._save" when creating the data object](https://git.coolaj86.com/coolaj86/greenlock-manager-fs.js/src/branch/master/manager.js#L283) I am using the [le-store-s3 create() function](https://github.com/llun/le-store-s3/blob/master/index.js#L3) to create the le store, then I used a recursive function to print out these "cyclic references" within the le store object as follows: ``` CIRCULAR: obj.s3.config.logger.streams.0.stream.stream.stream._handle.owner = obj.s3.config.logger.streams.0.stream.stream.stream = [object Object] CIRCULAR: obj.s3.config.logger.streams.1.stream.stream.stream.client._handle.owner = obj.s3.config.logger.streams.1.stream.stream.stream.client = [object Object] CIRCULAR: obj.keypairs.store = obj = [object Object] CIRCULAR: obj.configs.store = obj = [object Object] CIRCULAR: obj.accounts.store = obj = [object Object] CIRCULAR: obj.accounts.keypairs.store = obj = [object Object] CIRCULAR: obj.certificates.store = obj = [object Object] CIRCULAR: obj.certificates.keypairs.store = obj = [object Object] CIRCULAR: obj.certificates.configs.store = obj = [object Object] ``` The le store and the s3 logger stream handler owner appear to be "cyclic references" which cause `JSON.stringify` to throw. **Summary:** I'd greatly appreciate feedback and suggestions to help me help myself. I'm not sure if there's a "proper" fix for this or if I should just start hacking away? I'm assuming I'm not the first person attempting to upgrade to greenlock v4 using AWS S3 as the store, so hopefully this is something basic which I'm ignorant and unaware of?
Owner

I haven't tested this one myself, but I think what you want is the v3/v4-compatible s3 module:

https://git.rootprojects.org/root/gl-store-s3.js

npx greenlock defaults --store greenlock-store-s3

IIRC you can update the config by converting the keys from camelCase to hyphen-case for the CLI:

npx greenlock defaults --store greenlock-store-s3 --store-access-key-id aaaa --store-secret-access-key xxxx # and so on

And if you're using the default JSON config file in greenlock.d, you can verify and edit the file by hand - but as a general rule it's not intended to be edited by hand except for debugging.

I haven't tested this one myself, but I think what you want is the v3/v4-compatible s3 module: https://git.rootprojects.org/root/gl-store-s3.js ```bash npx greenlock defaults --store greenlock-store-s3 ``` IIRC you can update the config by converting the keys from `camelCase` to `hyphen-case` for the CLI: ```bash npx greenlock defaults --store greenlock-store-s3 --store-access-key-id aaaa --store-secret-access-key xxxx # and so on ``` And if you're using the default JSON config file in `greenlock.d`, you can verify and edit the file by hand - but as a general rule it's not intended to be edited by hand except for debugging.
Author

Thanks for your help AJ, I've found that I'm fundamentally using this API incorrectly. Please close this "issue". Thanks, Clayton

Thanks for your help AJ, I've found that I'm fundamentally using this API incorrectly. Please close this "issue". Thanks, Clayton
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: coolaj86/greenlock.js-ARCHIVED#49
No description provided.