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

ssb.friends.get Error #718

Closed
analoglesbian opened this issue Jun 30, 2021 · 27 comments
Closed

ssb.friends.get Error #718

analoglesbian opened this issue Jun 30, 2021 · 27 comments

Comments

@analoglesbian
Copy link

I just installed Oasis, since Patchwork is being sunsetted, and when I first launched it said it was processing my database, but once that finished, it gave me the following error message:

TypeError: ssb.friends.get is not a function
at socialFilter (/usr/local/lib/node_modules/@fraction/oasis/src/models.js:669:50)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async getMessages (/usr/local/lib/node_modules/@fraction/oasis/src/models.js:630:31)
at async Object.mentionsMe (/usr/local/lib/node_modules/@fraction/oasis/src/models.js:957:24)
at async mentions (/usr/local/lib/node_modules/@fraction/oasis/src/index.js:784:24)
at async /usr/local/lib/node_modules/@fraction/oasis/src/index.js:788:16
at async middleware (/usr/local/lib/node_modules/@fraction/oasis/src/index.js:1085:7)
at async /usr/local/lib/node_modules/@fraction/oasis/src/index.js:1063:5
at async /usr/local/lib/node_modules/@fraction/oasis/src/index.js:1058:5
at async /usr/local/lib/node_modules/@fraction/oasis/src/http.js:113:5

I've tried installing both the stable and unstable versions, and get this same error either way. Do I need to do anything special to import my Patchwork ssb database?

@mitra42
Copy link

mitra42 commented Jul 4, 2021

I'm seeing the exact same problem (and for the same reason)

@analoglesbian
Copy link
Author

analoglesbian commented Jul 4, 2021

I forgot to include that this was with Node v14.17.1 on MacOS v11.2.3.

I tried reinstalling Node completely, rolling it back to v12, and neither could get the instructions from the README to result in a working install.

However, I was able to get Oasis running by using npm build and npm start on the source tree for v2.17.0. I would not count this as a solution though, because the listed instructions still do not work, even after I was able to get a successful install by building from source.

@mitra42
Copy link

mitra42 commented Jul 4, 2021

Mine was Node v14.7.1 on MacOS v11.4 - i just saw there were a lot of errors in the oasis console - looks easy to replicate.

@lordcirth
Copy link

Ran into this issue today as well.

@mitra42
Copy link

mitra42 commented Jul 9, 2021

Did any of you find a way around this ?

@mitra42
Copy link

mitra42 commented Jul 17, 2021

ugg - Anyone got suggestions for an alternative to Oasis that works with old patchwork database :-( (on current Node and OSX?)

@retog
Copy link

retog commented Jul 27, 2021

I'm getting the same error in a fresh node:12-buster docker container, so this seems unrelated to the old database format.

@pospi
Copy link

pospi commented Aug 2, 2021

Also getting it here with Node 15.5.0, Ubuntu 20.04.2.

Unlike @analoglesbian I was not able to run the app from source (latest @ time of writing eabc34e, but the same as the last tagged release aside from package maintenance updates).

Looking at it now, node is still maxing out 4 CPUs with the erroring page in question open. It may just be that there is more data for Oasis yet to process. This would seem to be confirmed by a second error message being printed some time later (several minutes)-

  message: 'method:ebt,replicate is not in list of allowed methods',
  name: 'Error',
  stack: 'Error: method:ebt,replicate is not in list of allowed methods\n' +
    '    at Function.perms.pre (/app/node_modules/muxrpc/permissions.js:88:14)\n' +

I occasionally get ECONNRESET errors as well. Hard to know what the issue is, but certainly I have yet to see a working UI. Will leave it open for a few hours and loop back here if that changes.

@mitra42
Copy link

mitra42 commented Aug 17, 2021

Did you figure this out @pospi ?

@pospi
Copy link

pospi commented Aug 18, 2021 via email

@mitra42
Copy link

mitra42 commented Aug 31, 2021

That's hilarious @pospi - especially since the whole point is to get off of Patchwork because (according to the patchwork repo) its got problems and shouldn't be used. From the silence in this repo, I'm guessing Oasis's server isn't under active dev either, any suggestions for an alternative.

@almereyda
Copy link

I'm running into the same issue by following the instructions for building Oasis with Docker.

@nickwynja
Copy link
Collaborator

This is caused by #715. In [email protected], the legacy APIs were removed. npm install [email protected] gets Oasis working again.

@mhfowler
Copy link

mhfowler commented Sep 13, 2021

@nickwynja after running npm install [email protected], the next error I get is:

TypeError: Cannot read properties of undefined (reading 'getFileName')
    at module.exports (/srv/tools/oasis/node_modules/caller-path/index.js:4:40)
    at requireStyle (/srv/tools/oasis/node_modules/require-style/index.js:17:22)
    at /srv/tools/oasis/src/index.js:575:16
    at dispatch (/srv/tools/oasis/node_modules/koa-compose/index.js:42:32)
    at /srv/tools/oasis/node_modules/@koa/router/lib/router.js:372:16
    at dispatch (/srv/tools/oasis/node_modules/koa-compose/index.js:42:32)
    at /srv/tools/oasis/node_modules/koa-compose/index.js:34:12
    at dispatch (/srv/tools/oasis/node_modules/@koa/router/lib/router.js:377:31)
    at dispatch (/srv/tools/oasis/node_modules/koa-compose/index.js:42:32)
    at middleware (/srv/tools/oasis/src/index.js:1085:13)

@nickwynja
Copy link
Collaborator

@mhfowler Seems like the same issue as #688. Are you also on node 16?

@mhfowler
Copy link

@nickwynja thanks. I was on node 16, and I just now tried switching to 14 and now its working 🌵

@nickwynja
Copy link
Collaborator

nickwynja commented Sep 13, 2021

Even with this ssb.friends.get error resolved, Oasis seems to have trouble fetching/syncing/replicating new messages. Looking into that too since I think it's another updated or out-of-date dependency issue.

@mitra42
Copy link

mitra42 commented Sep 26, 2021

Any luck @nickwynja ?

@nickwynja
Copy link
Collaborator

@mitra42 I wasn't able to solve the dependency issues but locally reverted back to the last commit hash that wasn't a dependabot automated merge. That was 4e8f742. You can check out this version doing git checkout 4e8f7426a4eb1d95f6e55cf894a3168f523f8af8. Then I did a fresh install of node modules by doing rm -rf node_modules and then npm install. This got me a working version.

@mitra42
Copy link

mitra42 commented Sep 27, 2021

Thanks Nick - I'll give that a go.

I don't what the dev culture in this group is, but I'd have thought that maybe the package owner should revert out those dependabot merges for the "stable" version until someone has time to figure out the issues - I had to do that for one of the packages I'm admin for.

@mitra42
Copy link

mitra42 commented Sep 27, 2021

That worked, and it looks like it picked up my id and follows etc from the old Patchwork DB I copied over.
Looks like the full path to install and run is ...

git clone https://github.com/fraction/oasis.git
cd oasis
git checkout 4e8f7426a4eb1d95f6e55cf894a3168f523f8af8
oasis/src/index.js

Would you agree - and if so I wonder if I should do a Pull request on the README as, currently the install instructions (from npm) are incorrect for Mac users, and judging by the age of this bug it doesn't look like there is anyone with the skills and time to fix it?

@retog
Copy link

retog commented Sep 29, 2021

@christianbundy, can the breaking change be reverted?

@christianbundy
Copy link
Member

👍 I'd imagine either I or @nickwynja would merge a PR to revert this change.

@rhz
Copy link

rhz commented Oct 13, 2021

I can confirm that this error isn't related to patchwork. I was using oasis about a year ago and it was working without issues. I haven't used patchwork since then, yet I get this same error on most pages when running oasis now. I'm on node version 16.11.1. By downgrading to 14.17.4 I solve issue #688. By then doing

git pull
git checkout 4e8f7426a4eb1d95f6e55cf894a3168f523f8af8
rm -rf node_modules
npm install --only=prod
npm -g install .
systemctl --user restart oasis

on a local git clone I can re-install oasis globally and re-start the oasis server. As others said before, this new build doesn't give the ssb.friends.get error.

@nsantini
Copy link
Contributor

I got a solution in the code for using ssb-friends 5.0.0 (the one currently installed in the master branch)

diff --git a/src/models.js b/src/models.js
index 2e5dbac..6439f32 100644
--- a/src/models.js
+++ b/src/models.js
@@ -666,16 +666,22 @@ module.exports = ({ cooler, isPublic }) => {
   } = {}) => {
     const ssb = await cooler.open();
     const { id } = ssb;
-    const relationshipObject = await ssb.friends.get({
-      source: id,
-    });
+    const relationshipObject = await (new Promise((resolve, reject) => {
+      ssb.friends.graph((err, graph) => {
+        if (err) {
+          console.error(err)
+          reject(err)
+        }
+        resolve(graph[id] || {})
+      })
+    }))
 
     const followingList = Object.entries(relationshipObject)
-      .filter(([, val]) => val === true)
+      .filter(([, val]) => val >= 0)
       .map(([key]) => key);
 
     const blockingList = Object.entries(relationshipObject)
-      .filter(([, val]) => val === false)
+      .filter(([, val]) => val === -1)
       .map(([key]) => key);
 
     return pull.filter((message) => {

I'll try to open a PR with it

@nickwynja
Copy link
Collaborator

Would anyone following this thread be able to try running @nsantini's PR #784 to see if it works for you and continues to pull/stream/update posts? I'm not receiving any errors but also no new posts are syncing when running this branch so want to see if anyone else is seeing that same behavior.

@nickwynja
Copy link
Collaborator

This is now fixed in the master branch.

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

No branches or pull requests