-
Notifications
You must be signed in to change notification settings - Fork 325
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
Allows embedded IPFS node to be configured #395
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 for adding this, but linting (npm run lint:web-ext
) does not pass:
Code Message Description File Line Column
FILE_TOO_LARGE File is too large This file is not binary and is too dist/background/b…
to parse. large to parse. Files larger than ackground.js
4MB will not be parsed. If your
JavaScript file has a large list,
consider removing the list and
loading it as a separate JSON file
instead.
@lidel can we deal with the linting warning as a separate issue please? |
@lidel @olizilla I added this because I needed to enable pubsub on the js-ipfs node, but this is real power user stuff and is error prone for new users. Would it be better to just have a checkbox to enable pubsub instead and leave the JSON config to the power users who are probably running their own daemon anyway? |
LinterRule of thumb: we should never break build of I propose we park this PR until linting is fixed in separate PR, and then you can rebase this PR on top of that. JSON and UXIndeed, a field with JSON in it is error prone. Let's keep JSON-based config, but make sure the "Reset Everything" button restores config to safe defaults. We should also either add "(for Power Users)" to label description, or move it to "Experiments" section. |
On the subject of config... I say keep it simple. It's be helpful as a dev to know that I can build an app that will run if the user installs ipfs-companion as it has a fairly predictable config. They don't have to install a local go node or desktop, the defaults in companion will work. I'm not sure who we are catering for in making an easy to use embedded node also be "power-user" configurable. A simpler story would be "embedded node with defaults" for the casual user, "external node with custom config" or just, "create an app that bundles it's own custom ipfs node" if your app or use case has custom requirements. I'd be happy to start in that direction, and then see if anyone starts demanding more configurability of the embedded node and review. |
@lidel I'm happy for this PR to be blocked by the lint issue 👍 I appreciate that I opened this PR but I agree with @olizilla on this one - I think the stories should be casual -> embedded, expert -> external. I think JSON config is at odds with the casual embedded story. Here's the thing. If we don't have JSON config and we don't have an enable pubsub checkbox then people can't use pubsub with Why? Pubsub is disabled in Embedded js-ipfs is not configured to enable the pubsub experiment by default. |
Hm.. now that I think about it, I'd say pubsub is marked as an experiment by js-ipfs for a reason :) I propose we keep the "embedded node JSON config field" field in current form, but move it to to "Experiment" section (and update label to explicitly state that the config is for embedded node only). That way that there will be no confusion that this feature is an opt-in experiment that can changed or removed in the future. |
3bcfdc2
to
c2a75c1
Compare
@lidel rebased and lint error is now gone 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this requires additional error handling.
For example, what if user sets:
{
"config": {
"Addresses": {
"Swarm": [ "rekt" ]
}
}
}
According to my tests it is impossible to fix this right now, even via Reset button :(
Perhaps every use of initIpfsClient
in onStorageChange
should be wrapped by something like:
async function safeInitIpfsClient (state) {
try {
// in theory someone can set invalid config that breaks js-ipfs
// or we can introduce experiment that breaks things
// this wrapper makes sure it does not fail silently
return await initIpfsClient(state)
} catch (error) {
console.error('Unable to initialize API client due to error', error)
if (notify) notify('notify_addonIssueTitle', 'notify_addonIssueMsg')
// TODO: [restore old config value and update state object]
return await initIpfsClient(state)
}
}
Did not test if that is enough tho.
Not sure if related to this PR, but also found: #407 |
Ok so, you're saying that We can code around that particular issue, but it's going to be difficult to guard against all config issues. I can imagine a situation where users accidentally stop their node from communicating on the network or even cause it to error when particular methods are called due to the config they've copy/pasted from the internet or changed themselves. I don't think that's something we can, or even should be trying to guard against...like I said above, it's error prone and I think a checkbox to enable pubsub would be a safer option for casual users. As a side note, is the reset button not working for you? It should reset back to the default config. |
I agree we can't (and we should not) guard against broken config. Replication steps
I would really like to keep this "full config" feature, as it encourages playful experimentation, but we need to make it possible to self-heal. |
@lidel ok I'm on it! 👍 btw, how do you format a button in gfm? |
|
Blocked by ipfs/js-ipfs#1193 (comment) |
@alanshaw hi there! it looks like this won't be blocked anymore thanks to your work in PR ipfs/js-ipfs#1239 (though not upstreamed to a patch release yet). just wanted to make sure I'm following everything correctly. is that all correct? nice work, btw! |
Thanks, I think we're just waiting on it to be released now @cvan |
f1fc161
to
16fe8d7
Compare
@lidel I've taken another look at this, updated the IPFS dependency and fixed the stability issues you were seeing. There is now validation of config and feedback to the user and there's always a way to reset config and the extension acts gracefully when it fails to start an IPFS node. I'm happy for this to merge if you are. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation works perfect now, I was unable to brick it 👍
If you fix i18 key names and move config to the old place, I am ok to merge it.
add-on/_locales/en/messages.json
Outdated
@@ -169,6 +169,14 @@ | |||
}, | |||
"description": "A generic placeholder for error notification (notify_inlineErrorMsg)" | |||
}, | |||
"notify_startIpfsNodeTitle": { | |||
"message": "Failed to start IPFS node", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change key names to reflect that message is for a failure:
notify_startIpfsNodeTitle
notify_stopIpfsNodeTitle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha, oops I didn't mean to not indicate it was for a failure!
@@ -87,6 +90,17 @@ function experimentsForm ({ | |||
</label> | |||
<input type="checkbox" id="ipfs-proxy" onchange=${onIpfsProxyChange} checked=${ipfsProxy} /> | |||
</div> | |||
${ipfsNodeType === 'embedded' ? html` | |||
<div> | |||
<label for="ipfsNodeConfig"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we can safely recover any misconfiguration, lets move this back to the old place – below node type picker :)
@lidel looks good to you? |
👌 |
resolves #394
Simply adds a field in the options (if node type is embedded) that allows you to paste some JSON config. This allows the savvy user to configure their js-ipfs node as they like.
I've also removed the
is-js-ipfs-enabled
module as it is always enabled now (sorry that should probably be in another PR but is a small change so hopefully not too distracting).This PR also upgrades choo to fix this problem with textareas: choojs/choo#632