logseq / logseq

A privacy-first, open-source platform for knowledge management and collaboration. Download link: http://github.com/logseq/logseq/releases. roadmap: http://trello.com/b/8txSM12G/roadmap
https://logseq.com
GNU Affero General Public License v3.0
30.07k stars 1.76k forks source link

Electron app startup is very slow #11241

Open thief-sty opened 1 month ago

thief-sty commented 1 month ago

Search first

What Happened?

When running yarn e2e-test, the startup time for the Electron app can be very slow.

I have tried to adjust the timeout on the beforeAll hook to account for that (at e2e-tests/fixtures.ts:46, introducing base.slow() or base.setTimeout() with different values), but even with a 180s timeout, sometimes the timeout gets exceeded:

  1) basic.spec.ts:8:5 › create page and blocks, save to disk ───────────────────────

    "beforeAll" hook timeout of 180000ms exceeded.

       at fixtures.ts:45

      43 | }
      44 |
    > 45 | base.beforeAll(async () => {
         |      ^
      46 |   base.setTimeout(180000)
      47 |   if (electronApp) {
      48 |     return

        at /home/sty/Code/logseq/e2e-tests/fixtures.ts:45:6

I am currently hunting timeouts that are too short for e2e-tests to run correctly on my config, and this one is the one I have increased the most yet. I could theoretically increase it even further, but at this point I feel like it's a waste of time, and that there's probably a cause to be found somewhere in the code. I don't have any clues though.

Reproduce the Bug

Run e2e tests

Expected Behavior

No response

Screenshots

No response

Desktop or Mobile Platform Information

No response

Additional Context

No response

Are you willing to submit a PR? If you know how to fix the bug.

andelf commented 1 month ago

Use npx cross-env 'DEBUG=pw:browser' CI=true playwright test to debug browser init and check the logs.

thief-sty commented 1 month ago

This is the output I get on a 10s timeout:

Running 167 tests using 1 worker
°Creating test graph directory: /home/sty/Code/logseq/tmp/#e2e-test/@EG0B80p1Dj
  pw:browser <launching> /home/sty/Code/logseq/node_modules/electron/dist/electron -r /home/sty/Code/logseq/node_modules/playwright-core/lib/server/electron/loader.js --inspect=0 --remote-debugging-port=0 electron.js +0ms
  pw:browser <launched> pid=5346 +6ms
  pw:browser [pid=5346][err] Debugger listening on ws://127.0.0.1:38625/69e72233-4899-4292-ae98-cc631ed894a8 +103ms
  pw:browser [pid=5346][err] For help, see: https://nodejs.org/en/docs/inspector +1ms
  pw:browser <ws connecting> ws://127.0.0.1:38625/69e72233-4899-4292-ae98-cc631ed894a8 +0ms
  pw:browser <ws connected> ws://127.0.0.1:38625/69e72233-4899-4292-ae98-cc631ed894a8 +8ms
  pw:browser [pid=5346][err] Debugger attached. +1ms
F

  1) basic.spec.ts:8:5 › create page and blocks, save to disk ───────────────────────

    electron.launch: Timeout 10000ms exceeded.

       at fixtures.ts:55

      53 |   });
      54 |
    > 55 |   electronApp = await electron.launch({
         |                 ^
      56 |     cwd: "./static",
      57 |     args: ["electron.js"],
      58 |     locale: 'en',

        at /home/sty/Code/logseq/e2e-tests/fixtures.ts:55:17

  1 failed
    basic.spec.ts:8:5 › create page and blocks, save to disk ────────────────────────
  166 skipped

This is with a base.slow() marker (90s timeout):

Running 167 tests using 1 worker
°Creating test graph directory: /home/sty/Code/logseq/tmp/#e2e-test/@9hcHsyUbEA
  pw:browser <launching> /home/sty/Code/logseq/node_modules/electron/dist/electron -r /home/sty/Code/logseq/node_modules/playwright-core/lib/server/electron/loader.js --inspect=0 --remote-debugging-port=0 electron.js +0ms
  pw:browser <launched> pid=5719 +5ms
  pw:browser [pid=5719][err] Debugger listening on ws://127.0.0.1:43819/a2feedaf-1cf4-4560-bfd7-79f7f4719d48 +103ms
  pw:browser [pid=5719][err] For help, see: https://nodejs.org/en/docs/inspector +1ms
  pw:browser <ws connecting> ws://127.0.0.1:43819/a2feedaf-1cf4-4560-bfd7-79f7f4719d48 +0ms
  pw:browser <ws connected> ws://127.0.0.1:43819/a2feedaf-1cf4-4560-bfd7-79f7f4719d48 +11ms
  pw:browser [pid=5719][err] Debugger attached. +1ms
  pw:browser [pid=5719][err] (rsapi) init loggers +775ms
  pw:browser [pid=5719][err]  +7s
  pw:browser [pid=5719][err] DevTools listening on ws://127.0.0.1:36193/devtools/browser/2e0cce85-0f8d-4af5-a85c-bdb4f32f5fbf +0ms
  pw:browser <ws connecting> ws://127.0.0.1:36193/devtools/browser/2e0cce85-0f8d-4af5-a85c-bdb4f32f5fbf +1ms
  pw:browser <ws connected> ws://127.0.0.1:36193/devtools/browser/2e0cce85-0f8d-4af5-a85c-bdb4f32f5fbf +271ms
  pw:browser [pid=5719][out] shadow-cljs - #4 ready! +247ms
  pw:browser [pid=5719][out] 11:11:03.156 › Logseq App(27.1.3) Starting...  +3s
  pw:browser [pid=5719][out] 11:11:03.744 › restore proxy settings {:type "system"} +510ms
  pw:browser [pid=5719][out] 11:11:03.746 › set proxy to {:type "system"} +3ms
^[[CT

  1) basic.spec.ts:8:5 › create page and blocks, save to disk ───────────────────────

    "beforeAll" hook timeout of 90000ms exceeded.

       at fixtures.ts:45

      43 | }
      44 |
    > 45 | base.beforeAll(async () => {
         |      ^
      46 |   base.slow()
      47 |   if (electronApp) {
      48 |     return

        at /home/sty/Code/logseq/e2e-tests/fixtures.ts:45:6

  1 failed
    basic.spec.ts:8:5 › create page and blocks, save to disk ────────────────────────
  166 skipped

It doesn't seem to give any additional info.