Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

feat: share IPFS node between browser tabs #3081

Merged
merged 75 commits into from
Jul 27, 2020

Conversation

Gozala
Copy link
Contributor

@Gozala Gozala commented Jun 10, 2020

High level overview

This pull request adds 3 (sub)packages:

  1. ipfs-message-port-client - Provides an API to an IPFS node over the message channel.
  2. ipfs-message-port-server - Provides an IPFS node over message channel.
  3. ipfs-message-port-protocol - Shared code between client / server mostly related to wire protocol encoding / decoding.

Status

I consider implementation mostly complete, with some caveats (see below). I think it is ready

  1. All interface tests pass except:
  1. I'll be doing another pass to clean up things further & add doc / comments as needed.
  2. Unrelated tests are disabled due to intermittent failures that occur on master (See Flaky CI tests #3036). This changes aren't intended to be part of this pull.
  3. I have increased bundle size of ipfs-http-client (I just can't figure out what the size is changing, as I make no changes to it and no library seems to get bundled twice). This change isn't intended to be part of this pull.
  4. Some dependencies point to my forks, until changes in corresponding libraries propagate

Fixes #3022

@Gozala Gozala marked this pull request as draft June 10, 2020 20:43
@Gozala Gozala changed the title WIP: Sharing IPFS node Sharing IPFS node Jun 10, 2020
@Gozala Gozala requested review from achingbrain and lidel July 16, 2020 04:32
Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great work. Comments are inline but I think this is really close.

examples/browser-sharing-node-across-tabs/lerna.json Outdated Show resolved Hide resolved
packages/interface-ipfs-core/src/add.js Outdated Show resolved Hide resolved
packages/interface-ipfs-core/src/add.js Outdated Show resolved Hide resolved
packages/interface-ipfs-core/src/object/links.js Outdated Show resolved Hide resolved
@@ -113,7 +113,7 @@ module.exports = (common, options) => {
const cid = await ipfs.object.put(node1b)
const node = await ipfs.object.get(cid)
expect(node1b.Data).to.deep.equal(node.Data)
expect(node1b.Links).to.deep.equal(node.Links)
expect(node1b.Links).to.containSubset(node.Links)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the data over [message channel][] is copied via
[structured cloning algorithm][] it may lead to suboptimal
results (espacially with large binary data). In order to avoid unecessary
copying server will transfer all the [Transferable][] which will be emptied
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
copying server will transfer all the [Transferable][] which will be emptied
copying the server will transfer all passed [Transferable][]s which will be emptied

packages/ipfs-message-port-server/README.md Outdated Show resolved Hide resolved
packages/ipfs-message-port-server/test/basic.spec.js Outdated Show resolved Hide resolved
packages/ipfs-message-port-server/test/basic.spec.js Outdated Show resolved Hide resolved
packages/ipfs-message-port-server/src/core.js Show resolved Hide resolved
@achingbrain
Copy link
Member

Can you please:

  1. Merge master into this branch
  2. Ensure all dependency versions are aligned
    • To expand the monorepo to temporarily include the examples:
      1. Run these commands from the repo root
      2. Look at the end of the output from lerna, fix any warnings about dep versions differing from the hoisted version
      3. Run npm run reset && npm i from the repo root again until no warnings remain
      4. Ensure all examples depending on modules in the /packages directory depend on the same version as the one in the /packages directory
      5. Once everything is aligned, revert your changes to lerna.json

@Gozala Gozala requested a review from achingbrain July 25, 2020 02:59
@achingbrain achingbrain merged commit 1b8b1b8 into ipfs:master Jul 27, 2020
SgtPooki referenced this pull request in ipfs/js-kubo-rpc-client Aug 18, 2022
This pull request adds 3 (sub)packages:

1. `ipfs-message-port-client` - Provides an API to an IPFS node over the [message channel][MessageChannel].
2. `ipfs-message-port-server` - Provides an IPFS node over [message channel][MessageChannel].
3. `ipfs-message-port-protocol` - Shared code between client / server mostly related to wire protocol encoding / decoding.

Fixes #3022

[MessageChannel]:https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel

Co-authored-by: Marcin Rataj <[email protected]>
Co-authored-by: Alex Potsides <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sharing IPFS node across browsing contexts (tabs) on same origin
3 participants