samepage-network / samepage.network

samepage.network
MIT License
10 stars 2 forks source link

Issues running samepage dev #62

Closed mdroidian closed 1 year ago

mdroidian commented 1 year ago

Here's the first go, I'm stuck on the mysql step @dvargas92495 :

On Windows, so used WSL2 to git clone to handle : in folder names.

dvargas92495 commented 1 year ago

This was on npx ts-node scripts/cli.ts apply --sql not plan correct? If so, then I think this is okay and the migrations we care about should have ran.

We'll want npx ts-node scripts/cli.ts apply --sql --bare in that onboarding step, and in the future, I want to think about a better way to manage data migrations

mdroidian commented 1 year ago

This was on npx ts-node scripts/cli.ts apply --sql not plan correct? I'll double check this in a minute.

I tried again on a different system. This time I got some errors running npm install, then errors at npx ts-node scripts/cli.ts plan --sql

npm install

npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path \\wsl$\Ubuntu-20.04\home\mdroid\SamePage\samepage.network\node_modules\abab
npm ERR! dest \\wsl$\Ubuntu-20.04\home\mdroid\SamePage\samepage.network\node_modules\.abab-l8YGm0oL
npm ERR! errno -4051
npm ERR! ENOTEMPTY: directory not empty, rename '\\wsl$\Ubuntu-20.04\home\mdroid\SamePage\samepage.network\node_modules\abab' -> '\\wsl$\Ubuntu-20.04\home\mdroid\SamePage\samepage.network\
node_modules\.abab-l8YGm0oL'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mclic\AppData\Local\npm-cache\_logs\2023-04-19T18_19_50_975Z-debug-0.log

npx ts-node scripts/cli.ts plan --sql

'\\wsl$\Ubuntu-20.04\home\mdroid\SamePage\samepage.network'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module './cli.ts'
Require stack:
- C:\Windows\scripts\imaginaryUncacheableRequireResolveScript
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Function.resolve (node:internal/modules/cjs/helpers:109:19)
    at requireResolveNonCached (C:\Users\mclic\AppData\Local\npm-cache\_npx\1bf7c3c15bf47d04\node_modules\ts-node\dist\bin.js:549:16)
    at getProjectSearchDir (C:\Users\mclic\AppData\Local\npm-cache\_npx\1bf7c3c15bf47d04\node_modules\ts-node\dist\bin.js:519:40)
    at phase3 (C:\Users\mclic\AppData\Local\npm-cache\_npx\1bf7c3c15bf47d04\node_modules\ts-node\dist\bin.js:267:27)
    at bootstrap (C:\Users\mclic\AppData\Local\npm-cache\_npx\1bf7c3c15bf47d04\node_modules\ts-node\dist\bin.js:47:30)
    at main (C:\Users\mclic\AppData\Local\npm-cache\_npx\1bf7c3c15bf47d04\node_modules\ts-node\dist\bin.js:33:12)
    at Object.<anonymous> (C:\Users\mclic\AppData\Local\npm-cache\_npx\1bf7c3c15bf47d04\node_modules\ts-node\dist\bin.js:579:5)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'C:\\Windows\\scripts\\imaginaryUncacheableRequireResolveScript' ]
}

Node.js v18.12.1
mdroidian commented 1 year ago

Alright, maybe third time is the charm. Upgraded to Ubuntu 22.04

/home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:48383 const createConnectionErr = new Error(); ^

Error: Access denied for user 'samepage_network'@'localhost' to database 'samepage_network' at createConnection2 (/home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:48383:35) at mysqlIntrospect (/home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:49138:60) at Command2. (/home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:49693:41) at Command2.listener [as _actionHandler] (/home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:856:21) at /home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:1284:69 at Command2._chainOrCall (/home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:1216:16) at Command2._parseCommand (/home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:1284:31) at /home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:1153:31 at Command2._chainOrCall (/home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:1216:16) at Command2._dispatchSubcommand (/home/mdroid/samepage/samepage.network/node_modules/drizzle-kit/index.js:1149:27) { code: 'ER_DBACCESS_DENIED_ERROR', errno: 1044, sqlState: '42000' }

Node.js v20.0.0 Error: Command failed: npx drizzle-kit introspect:mysql --out out/migrations --connectionString='mysql://samepage_network:samepage_network@localhost:3306/samepage_network' at checkExecSyncError (node:child_process:885:11) at execSync (node:child_process:957:15) at compareSqlSchemas (/home/mdroid/samepage/samepage.network/data/compareSqlSchemas.ts:8:11) at plan (/home/mdroid/samepage/samepage.network/scripts/commands/plan.ts:13:28) at run (/home/mdroid/samepage/samepage.network/scripts/cli.ts:77:18) at Object. (/home/mdroid/samepage/samepage.network/scripts/cli.ts:106:1) at Module._compile (node:internal/modules/cjs/loader:1267:14) at Module.m._compile (/home/mdroid/samepage/samepage.network/node_modules/ts-node/src/index.ts:1618:23) at Module._extensions..js (node:internal/modules/cjs/loader:1321:10) { status: 1, signal: null, output: [ null, null, null ], pid: 5117, stdout: null, stderr: null }

mdroidian commented 1 year ago

CREATE DATABASE samepage_network; GRANT ALL PRIVILEGES ON samepage_network TO 'samepage_network'@'localhost'; npx ts-node scripts/cli.ts plan --sql

18 tables
access_tokens 4 columns 1 indexes 0 fks
apps 5 columns 1 indexes 0 fks
authorization_codes 6 columns 0 indexes 0 fks
client_sessions 5 columns 2 indexes 0 fks
interviews 5 columns 2 indexes 0 fks
messages 7 columns 4 indexes 0 fks
_migrations 5 columns 0 indexes 0 fks
notebook_requests 7 columns 1 indexes 0 fks
notebooks 3 columns 0 indexes 0 fks
oauth_clients 3 columns 0 indexes 0 fks
ongoing_messages 3 columns 1 indexes 0 fks
online_clients 3 columns 1 indexes 0 fks
page_notebook_links 10 columns 5 indexes 0 fks
page_properties 4 columns 2 indexes 0 fks
pages 2 columns 0 indexes 0 fks
quotas 4 columns 0 indexes 0 fks
token_notebook_links 3 columns 3 indexes 0 fks
tokens 4 columns 0 indexes 0 fks

mdroidian commented 1 year ago

npx ts-node scripts/cli.ts apply --sql

some typescript errors

data/migrations/2022-10-24-17-09-migrate-message-operations.ts:1:37 - error TS2307: 
Cannot find module '@dvargas92495/app/backend/downloadFile.server' or its corresponding type declarations.

1 import { downloadFileContent } from "@dvargas92495/app/backend/downloadFile.server";
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
data/migrations/2022-10-24-17-09-migrate-message-operations.ts:2:37 - error TS2307: 
Cannot find module 'fuegojs/types' or its corresponding type declarations.

2 import type { MigrationProps } from "fuegojs/types";
                                      ~~~~~~~~~~~~~~~
data/migrations/2022-10-24-17-09-migrate-message-operations.ts:7:13 - error TS7031: 
Binding element 'msgs' implicitly has an 'any' type.
7     .then(([msgs]) => {
              ~~~~
data/migrations/2022-10-24-17-09-migrate-message-operations.ts:12:22 - error TS7006: 
Parameter 'content' implicitly has an 'any' type.
12               .then((content) => {
                        ~~~~~~~
data/migrations/2022-10-24-17-09-migrate-message-operations.ts:25:32 - error TS7006: 
Parameter 'res' implicitly has an 'any' type.
25                   .then(async (res) => {
                                  ~~~
data/migrations/2022-10-24-17-09-migrate-message-operations.ts:38:23 - error TS7006: 
Parameter 'e' implicitly has an 'any' type.
38               .catch((e) => {
                         ~
mdroidian commented 1 year ago

We'll want npx ts-node scripts/cli.ts apply --sql --bare in that onboarding step

Sorry, which step? Should npx ts-node scripts/cli.ts apply --sql be replaced with npx ts-node scripts/cli.ts apply --sql --bare ?

dvargas92495 commented 1 year ago

For your first comment:

Second comment:

Third comment:

Fourth comment:

Fifth comment: yes

mdroidian commented 1 year ago

Access denied for user means the password isn't set. Our scripts expect a local password of samepage_network.

I think the local password was already set here: CREATE USER 'samepage_network'@'localhost' IDENTIFIED BY 'samepage_network';

This fixed it: CREATE DATABASE samepage_network; GRANT ALL PRIVILEGES ON samepage_network TO 'samepage_network'@'localhost';

What happens if you now run npx ts-node scripts/cli.ts apply --sql --bare? That actually creates the mysql tables locally.

I already ran npx ts-node scripts/cli.ts apply --sql 😀 Tables made:

mysql> show tables;
+----------------------------+
| Tables_in_samepage_network |
+----------------------------+
| _migrations                |
| access_tokens              |
| apps                       |
| authorization_codes        |
| client_sessions            |
| interviews                 |
| messages                   |
| notebook_requests          |
| notebooks                  |
| oauth_clients              |
| ongoing_messages           |
| online_clients             |
| page_notebook_links        |
| page_properties            |
| pages                      |
| quotas                     |
| token_notebook_links       |
| tokens                     |
+----------------------------+
18 rows in set (0.00 sec)

Running npx ts-node scripts/cli.ts apply --sql --bare replied with No mysql schema queries to run!

mdroidian commented 1 year ago
dvargas92495 commented 1 year ago

Running npx ts-node scripts/cli.ts apply --sql --bare replied with No mysql schema queries to run!

cool then I think that's all set. --bare skips the data/migrations. Since schema migrations run before data ones do, they were created on the first error'd run.

running roam-samepage locally

So we're also going to need to seed your database with records in the apps table. I should create a script to make this easier. Try running: INSERT INTO samepage_network.apps (id, code, name, workspace_label, live) VALUES (1, 'roam', 'Roam', 'graph', false)

mdroidian commented 1 year ago

Same errors:

generic Error: Error: Value of "this" must be of type URLSearchParams

dvargas92495 commented 1 year ago

Are there any line numbers or hints of that sort in the terminal for the network?

mdroidian commented 1 year ago

Oddly, no. When I manually go to http://localhost:3003/page I get Route not found: GET - /page /favicon.ico And in my previous tests, normally that would show up in the terminal for the network. But not this time.

dvargas92495 commented 1 year ago

http://localhost:3003 points to our API server, so it won't load anything in the browser since there are no routes configured.

what does the network tab in the roam window look like for that request? in particular the headers and body params?

mdroidian commented 1 year ago

Headers

Request URL: http://localhost:3003/page
Request Method: POST
Status Code: 500 Internal Server Error
Remote Address: [::1]:3003
Referrer Policy: strict-origin-when-cross-origin
Access-Control-Allow-Origin: https://roamresearch.com
Connection: keep-alive
Content-Length: 7
Content-Type: text/html; charset=utf-8
Date: Wed, 19 Apr 2023 20:15:16 GMT
ETag: W/"7-TBTwzmWo4oZAIfPBUD6IOrpE0zE"
Keep-Alive: timeout=5
X-Powered-By: Express
Provisional headers are shown
Learn more
Content-Type: application/json
Referer
sec-ch-ua: "Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36

Payload

{notebookUuid: "", token: "", method: "add-notebook", email: "mclicks+samepagetest@gmail.com",…}
app: "roam"
email:"mclicks+samepagetest@gmail.com"
method:"add-notebook"
notebookUuid:""
password:"123456abc!"
token:""
workspace:"roamjs-manager"
mdroidian commented 1 year ago

On Windows: npm start

Error: spawn npx ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn npx',
  path: 'npx',
  spawnargs: [ 'tailwindcss', '-o', './app/tailwind.css', '--watch' ]
}
mdroidian commented 1 year ago

npx ts-node scripts/cli.ts plan --sql

drizzle-kit: v0.17.0
drizzle-orm: v0.22.0

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:371:5)
    at onParseError (node:internal/url:552:9)
    at new URL (node:internal/url:628:5)
    at Function.parseUrl (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\node_modules\drizzle-kit\index.js:45604:27)
    at new ConnectionConfig (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\node_modules\drizzle-kit\index.js:45456:38)
    at Object.exports.createConnection (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\node_modules\drizzle-kit\index.js:48103:40)
    at createConnection2 (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\node_modules\drizzle-kit\index.js:48382:35)
    at mysqlIntrospect (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\node_modules\drizzle-kit\index.js:49138:60)
    at Command2.<anonymous> (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\node_modules\drizzle-kit\index.js:49693:41)
    at Command2.listener [as _actionHandler] (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\node_modules\drizzle-kit\index.js:856:21) {
  input: "'mysql://samepage_network:samepage_network@localhost:3306/samepage_network'",
  code: 'ERR_INVALID_URL'
}
Error: Command failed: npx drizzle-kit introspect:mysql --out out\migrations --connectionString='mysql://samepage_network:samepage_network@localhost:3306/samepage_network'
    at checkExecSyncError (node:child_process:828:11)
    at execSync (node:child_process:902:15)
    at compareSqlSchemas (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\data\compareSqlSchemas.ts:8:11)
    at plan (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\scripts\commands\plan.ts:13:28)
    at run (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\scripts\cli.ts:77:18)
    at Object.<anonymous> (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\scripts\cli.ts:106:1)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Module.m._compile (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\node_modules\ts-node\src\index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\node_modules\ts-node\src\index.ts:1621:12) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 12632,
  stdout: null,
  stderr: null
}
dvargas92495 commented 1 year ago

It's complaining about the DATABASE_URL: mysql://samepage_network:samepage_network@localhost:3306/samepage_network

dvargas92495 commented 1 year ago

[ 'tailwindcss', '-o', './app/tailwind.css', '--watch' ]

were the dependencies npm install'd?

mdroidian commented 1 year ago

dependencies

Yup. image

mysql

port in my.ini defined as 3306 samepage_network database exists

🤔

dvargas92495 commented 1 year ago

On this line: https://github.com/samepage-network/samepage.network/blob/main/data/compareSqlSchemas.ts#L9

What happens if you replace the single quote with double quotes?

mdroidian commented 1 year ago

That fixed npx ts-node scripts/cli.ts plan --sql / apply

But npm start still has the same errors.

dvargas92495 commented 1 year ago

npm start won't have the drizzle-kit introspect:mysql callstack - so won't be exactly the same. how do you have DATABASE_URL set in your .env?

mdroidian commented 1 year ago

DATABASE_URL=mysql://samepage_network:samepage_network@localhost:3306/samepage_network

mdroidian commented 1 year ago

adding {shell: true,} to spawn fixes it.

mdroidian commented 1 year ago

"Create an account to link this notebook" with roam-notebook now gives error: Failed to fetch

Chrome console: Mixed Content: The page at 'https://roamresearch.com/#/app/roamjs-manager' was loaded over HTTPS, but requested an insecure resource 'http://172.20.76.241:3003/page'. This request has been blocked; the content must be served over HTTPS.

Nothing in the samepage.network terminal

dvargas92495 commented 1 year ago

adding {shell: true,} to spawn fixes it.

where did you add this?

Chrome console: Mixed Content

fascinating. what if you switched the API_URL back to localhost by removing it from .env?

mdroidian commented 1 year ago

image I'm in! But disconnected. I just redid it on my Windows Laptop.

Here's where I'm at now:

The connect command doesn't always show up image

When it did one time, a spinner just showed up, but not responses or console logs

image

mdroidian commented 1 year ago

fascinating. what if you switched the API_URL back to localhost by removing it from .env?

I'll test this on my desktop later today.

adding {shell: true,} to spawn fixes it.

where did you add this?

scripts/commands/dev.ts https://github.com/mdroidian/samepage.network/commit/98cc47ff13ec9144ba1b5f68c346359a4155afe0#r110036947

mdroidian commented 1 year ago

fascinating. what if you switched the API_URL back to localhost by removing it from .env?

Well this is interesting. On my desktop I'm still getting the Mixed content error. I'm not sure why I didn't get it on my Laptop. Removing API_URL=http://172.20.76.241:3003 from roam-samepage results in

email mclicks+samepage@gmail.com Create an account to link this notebook Error: That email address is taken. Please try another.

Add this notebook to your account Error: Could not find token to use for this user. Please contact support@samepage.network for help.

email newEmail@gmail.com Create an account to link this notebook TypeError: Cannot destructure property 'value' of 'q' as it is undefined.

Add this notebook to your account Error: No user found with email newEmail@gmail.com. Please create an account first.

dvargas92495 commented 1 year ago

ooooh I see what's happening. In oder:

1) Expected error

2) We have a webhook on Clerk that assigns a user a token whenever a new one is created. That webhook did not hit your local endpoint bc it's set up to hit mine. I'll have to think through what a proper workaround here is (my first thought is to start setting up clerk in /mocks), but in the meantime, you could look at the code in /api/user/post.ts to see how to manually give yourself a token.

3) I'm stumped on this one. Errors like this it's helpful to give a stacktrace.

4) Expected error

mdroidian commented 1 year ago

I'm trying to put some breakpoints in Onboarding.tsx, but it doesn't seem to load in Chrome Dev tools. Is there a reason for that or something I can do to get it to load?

I'd like to take a look at the stacktrace and see what variables are available ( userId / Id, etc).

Could not load content for https://roamresearch.com/node_modules/package/components/Onboarding.tsx (HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE) image

dvargas92495 commented 1 year ago

damn yea this is a known issue - this is the push I needed to finally address this. Will look to make it accessible tonight

dvargas92495 commented 1 year ago

Okay, latest versions of [roam/obsidian/logseq]-samepage should have this fixed

mdroidian commented 1 year ago

so I threw this in api/page/post.ts to generate a token for myself:

        getMysql().then((cxn) =>
          cxn
            .select({
              count: sql`COUNT(uuid)`,
            })
            .from(tokens)
            .where(eq(tokens.userId, userId))
            .then(async ([a]) =>
              !a?.count
                ? await cxn.insert(tokens).values({
                    uuid: v4(),
                    value: await randomString({
                      length: 12,
                      encoding: "base64",
                    }),
                    createdDate: new Date(),
                    userId,
                  })
                : Promise.resolve()
            )
            .then(() => cxn.end())
        );

Now I'm at this error when either "Create an account ..." or "Add this notebook ..."

POST request to http://localhost:3003/page failed: TypeError: Cannot destructure property 'value' of 'q' as it is undefined.

instrument.ts:163     POST http://localhost:3003/page 500 (Internal Server Error)
t @ instrument.ts:163
handleFetch @ apiClient.ts:35
(anonymous) @ apiClient.ts:96
apiClient3 @ apiClient.ts:126
(anonymous) @ Onboarding.tsx:37
Wa @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:234
Ca @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:234
ya @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:234
yd @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:260
le @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:261
(anonymous) @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:272
Sk @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:460
xb @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:233
Af @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:264
za @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:250
Ga @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:249
(anonymous) @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:210
rh @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:279
zb @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:459
Vb @ main.js?__WB_REVISION__=e8a54fbd9296189f82fa2b4ecced3c44:248
sentryWrapped @ helpers.ts:98
dvargas92495 commented 1 year ago

what does the stack trace in the backend look like?

mdroidian commented 1 year ago

No logs in the samepage.network console

If I load http://localhost:3000/, I get GET / 200 - - 107.395 ms But clicking on Roam Samepage "Connect", no logs.

dvargas92495 commented 1 year ago

I found the issue - I don't think you have the quotas table filled and we're not failing gracefully. I just pushed a commit to address both of these points

mdroidian commented 1 year ago

So I git pulled and added the STRIPE_SECRET_KEY and was able to connect an account. (without running npx) But the popup was off to the side, so I reloaded. Now I'm stuck at this. (see video)

I cleared the site data, that didn't help. This is the second graph this has happened to now.

I went ahead and tried to run npx and got

No mysql schema queries to run!
ReferenceError: fetch is not defined
    at apply (C:\Users\Michael\Desktop\Areas\RoamJS\SamePage Repos\samepage.network\scripts\commands\apply.ts:174:24)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

https://user-images.githubusercontent.com/3792666/235264462-13d0af33-8a53-4895-87c5-d7e50c9a2d4b.mp4

mdroidian commented 1 year ago

Fresh graph

https://user-images.githubusercontent.com/3792666/235265270-1b495102-0ef0-4017-a4d0-12764642c022.mp4

dvargas92495 commented 1 year ago

Now I'm stuck at this

Haven't seen it hang like that before. In the Network tab, there should be a line item for ws:127.0.0.1 which represents the WebSocket connection the extension is trying to make with your SamePage local backend. What are the messages that are outputted in this tab?

ReferenceError: fetch is not defined

Make sure you're on node version >= 18

Fresh graph

Oh wow. Ok I put together a video giving some debugging pointers: https://www.loom.com/share/8cc968c054bd422a9cd70d2f74b15340

mdroidian commented 1 year ago

Make sure you're on node version >= 18

This fixed the fetch issue

It looks like I'm not getting a response back in the web socket, nor is that handler being called.

https://user-images.githubusercontent.com/3792666/235331249-cc7f99f1-b5d3-4905-8a6c-5b25b8127b3d.mp4

Here's a run where I disconnect samepage.network to get the spinner to go away and add the connect command. Then I threw in a bunch of breakpoints.

https://user-images.githubusercontent.com/3792666/235331180-07f4f051-e1a2-4bd7-84ec-32c410da623e.mp4

mdroidian commented 1 year ago

No console logs in sendmessage.ts, ondisconnect.ts, onconnect.ts, nor setupWsFeatures.ts return.

How do you run the debugger? I wrote down DEBUG=api,sendmessage npm start but that command is not recognized

dvargas92495 commented 1 year ago

oh right you're on windows. You could throw DEBUG=api,sendmessage in your .env file before running npm start for the same effect

mdroidian commented 1 year ago

https://github.com/samepage-network/samepage.network/blob/8c7149843136eb7efbfabde3794029dfdf7ca9f3/scripts/commands/api.ts#L480 filepath is undefined for windows.

I'll change it to something like

const dirPath = require("path");
const filePath = wsEntries.find((f) =>
f.endsWith(dirPath.join("ws", action))
);

I'm in! 🤘 image

mdroidian commented 1 year ago

I'm trying to share a page to another roam graph. I believe this other roam graph may have run through the onboarding with a different email address and was assigned a notebookUuid. When I try to connect, I get the error

Uncaught Server Error: Could not find Notebook with the Universal Id: aa8...

I'm having trouble locating where the notebookUuid is stored for this graph. I've cleared the application storage and searched the mysql databases.

I'd like to disconnect this notebook and re-run it through the onboarding.

dvargas92495 commented 1 year ago

NotebookUUid is stored in the Roam Depot Settings. In the /admin/notebooks, you have the ability to delete notebooks

mdroidian commented 1 year ago

It looks like I'm not getting the extensionAPI.settings.panel

I'm also not sure why I'm not getting some of these await console.logs, or I'm not triggering breakpoints on loading the extension.

I was going to add extensionAPI.settings.set somewhere to remove my notebookuuid, but with runExtension not triggering, I'm quite confused.

https://user-images.githubusercontent.com/3792666/236361400-557c46a7-a498-4681-ab5f-c326e425f80e.mp4

dvargas92495 commented 1 year ago
mdroidian commented 1 year ago

Pulling resolved it.

On to Obsidian: I got a few pages shared, but now, when accepting a page, I get this error:

Failed to process notification: [
{
 "code": "invalid_type",
 "expected": "object",
 "received": "undefined",
 "path": [],
 "message". "Required"
}
]
POST http://localhost:3003/errors 500 (Internal Server Error)
  handleFetch @ plugin:samepage:28148
  eval @ plugin:samepage:28173
  sendExtensionError @ plugin:samepage:28250
  eval @ plugin:samepage:62576
  Promise.catch (async)
  onClick @ plugin:samepage:62574
  callCallback2 @ plugin:samepage:10077
  invokeGuardedCallbackDev @ plugin:samepage:10102
  invokeGuardedCallback @ plugin:samepage:10136
  invokeGuardedCallbackAndCatchFirstError @ plugin:samepage:10139
  executeDispatch @ plugin:samepage:13419
  processDispatchQueueItemsInOrder @ plugin:samepage:13439
  processDispatchQueue @ plugin:samepage:13448
  dispatchEventsForPlugins @ plugin:samepage:13456
  eval @ plugin:samepage:13580
  batchedUpdates$1 @ plugin:samepage:25312
  batchedUpdates @ plugin:samepage:9982
  dispatchEventForPluginEventSystem @ plugin:samepage:13579
  dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ plugin:samepage:11881
  dispatchEvent @ plugin:samepage:11875
  dispatchDiscreteEvent @ plugin:samepage:11852
Uncaught (in promise) Error: POST request to http://localhost:3003/errors failed: Region is missing
    at eval (plugin:samepage:28150:54)
eval @ plugin:samepage:28150