ebanDev / AnytypeCapture

This project aims to provide a quick and efficient way to capture any thought to your AnyType second brain. It leverages the protobuf GRPC API exposed by AnyType.
GNU Affero General Public License v3.0
7 stars 1 forks source link

Crash on first run #1

Open Eloitor opened 2 months ago

Eloitor commented 2 months ago

I followed the instructions in the README:

  1. Clone the repository: git clone https://github.com/ebanDev/AnytypeCapture.git
  2. Navigate to the project directory: cd AnytypeCapture
  3. Install the required dependencies: npm install
  4. Create the .env file: touch .env
  5. Start the application: npm start

I'm on void linux.

👉 Enter the content: Hello
node:internal/modules/run_main:115
    triggerUncaughtException(
    ^

Error: 14 UNAVAILABLE: Failed to parse DNS address dns:127.0.0.1:NaN
    at callErrorFromStatus (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/client.js:193:76)
    at Object.onReceiveStatus (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141)
    at Object.onReceiveStatus (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
    at /home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/resolving-call.js:129:78
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
for call at
    at ServiceClientImpl.makeUnaryRequest (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/client.js:161:32)
    at ServiceClientImpl.<anonymous> (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
    at node:internal/util:431:21
    at new Promise (<anonymous>)
    at ServiceClientImpl.<anonymous> (node:internal/util:417:12)
    at call (file:///home/eloi/AnytypeCapture/index.js:30:56)
    at fetchAppKey (file:///home/eloi/AnytypeCapture/index.js:44:32)
    at createAuthenticatedClient (file:///home/eloi/AnytypeCapture/index.js:33:37)
    at async file:///home/eloi/AnytypeCapture/index.js:93:30 {
  code: 14,
  details: 'Failed to parse DNS address dns:127.0.0.1:NaN',
  metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}

Node.js v22.4.0
ebanDev commented 2 months ago

Hey, thanks for bringing this to my attention! What is the output of lsof -i -P -n | grep LISTEN | grep "anytype" | awk '{print $9}' | cut -d: -f2 | paste -sd "," ?

Eloitor commented 2 months ago

44893,44445,40799

I had to install lsof for this to work. After that, I get the prompt to enter the token. After that:

 Enter the token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
node:internal/modules/run_main:115
    triggerUncaughtException(
    ^

Error: 16 UNAUTHENTICATED: session is not registered
    at callErrorFromStatus (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/client.js:193:76)
    at Object.onReceiveStatus (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141)
    at Object.onReceiveStatus (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
    at /home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/resolving-call.js:129:78
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
for call at
    at ServiceClientImpl.makeUnaryRequest (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/client.js:161:32)
    at ServiceClientImpl.<anonymous> (/home/eloi/AnytypeCapture/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
    at node:internal/util:431:21
    at new Promise (<anonymous>)
    at ServiceClientImpl.<anonymous> (node:internal/util:417:12)
    at call (file:///home/eloi/AnytypeCapture/index.js:30:56)
    at chooseType (file:///home/eloi/AnytypeCapture/index.js:54:30)
    at createObjectWithContent (file:///home/eloi/AnytypeCapture/index.js:67:38)
    at file:///home/eloi/AnytypeCapture/index.js:95:7
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 16,
  details: 'session is not registered',
  metadata: Metadata {
    internalRepr: Map(1) { 'content-type' => [ 'application/grpc' ] },
    options: {}
  }
}

Node.js v22.4.0
ebanDev commented 2 months ago

Ah thanks I'm going to add the lsof as a required install step. Could you show me your .env file (REDACT THE ACTUAL TOKEN)

Eloitor commented 2 months ago

Ohh I finally got a token from Anytype (I don't think I got it the first time). I thought the token was the vault key.

Now when I'm prompted to select a type I don't know what I'm expected to input, the number? the name? or the full string number + name?

Eloitor commented 2 months ago

I got it to work! Thanks for making this.

If I have more spaces, I get a type for each space, I see this:

🏷 Available types: [
  '0: Audio',           '1: Book',             '2: Bookmark',
  '3: Bug (Software)',  '4: Class Note',       '5: Collection',
  '6: Contact',         '7: Daily Plan',       '8: Dashboard',
  '9: Date',            '10: Diary Entry',     '11: Document',
  '12: Feature',        '13: File',            '14: Goal',
  '15: Idea',           '16: Image',           '17: Movie',
  '18: Note',           '19: Type',            '20: Page',
  '21: Space member',   '22: Human',           '23: Project',
  '24: Recipe',         '25: Relation',        '26: Relation option',
  '27: Set',            '28: Space',           '29: Space',
  '30: Task',           '31: Template',        '32: Video',
  '33: Weekly Plan',    '34: Image',           '35: Discussion',
  '36: Video',          '37: Human',           '38: Dashboard',
  '39: Bookmark',       '40: Date',            '41: Relation option',
  '42: Space',          '43: Task',            '44: Video',
  '45: Usecase',        '46: Space',           '47: Page',
  '48: Dashboard',      '49: Set',             '50: Daily Plan',
  '51: Date',           '52: Human',           '53: Space',
  '54: Item',           '55: Bug (Software)',  '56: Relation',
  '57: Note',           '58: Relation',        '59: Task',
  '60: Space',          '61: File',            '62: Template',
  '63: Image',          '64: Card',            '65: Space',
  '66: Relation',       '67: Collection',      '68: Space member',
  '69: Space',          '70: Library',         '71: Date',
  '72: Set',            '73: Video',           '74: Event',
  '75: University',     '76: Relation option', '77: Collection',
  '78: Date',           '79: Space',           '80: Relation option',
  '81: Article',        '82: Space member',    '83: Image',
  '84: Help',           '85: File',            '86: Space',
  '87: Bug (Software)', '88: Document',        '89: Template',
  '90: Video',          '91: Project',         '92: Type',
  '93: Image',          '94: Template',        '95: Talk',
  '96: Dashboard',      '97: Relation option', '98: Collection',
  '99: Application',
  ... 118 more items
]

I have to guess to which space does every number correspond.

ebanDev commented 2 months ago

Ah you're right, you are supposed to input the corresponding number, I will add that. And for the space selection it currently only supports one space but I will add support for multiple spaces in the future :)

Eloitor commented 2 months ago

Could you use something like https://www.npmjs.com/package/@inquirer/prompts to prompt the user for the default type? The user selects the type from the list instead of having to type it.

It also avoid the "... 118 more items" problem.

ebanDev commented 2 months ago

yup I'm definitely gonna do that