laurent22 / joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
https://joplinapp.org
Other
46.35k stars 5.04k forks source link

"Cannot read property 'decryptedItemCount' of undefined" in terminal app #4000

Closed ambrt closed 4 years ago

ambrt commented 4 years ago

So basically i synced fresh terminal app via dropbox and went with e2ee decrypt. Provided passwords (since i have 3 master keys).

And i got this in terminal's console: Cannot read property 'decryptedItemCount' of undefined

At this moment i think that terminal app is doing something because there is write activity of around 200KB/s. About 70% of notes got decrypted but i don't know if it still decrypts rest of them or got stuck (it has been on for 4h )

ambrt commented 4 years ago

Looking at log i found that most recent entries seems to say its decrypting. I guess its just slow (can anyone confirm that? i have about 10k items with some 2k notes)

The Cannot read property 'decryptedItemCount' of undefined seem to be shown when i put e2ee decrypt command "again" - since according to log its already started on terminal app start.

["decrypt:6:62245d8fdb7047618928de3ee1bee30a",1,1,1603999199314]"
                SELECT *
                FROM `tags`
                WHERE encryption_applied = 1 AND id NOT IN ("[lots of id here]")
                LIMIT 100
                "
ambrt commented 4 years ago

If someone will bump into similar thing i had one of 3 master keys not loaded Code: masterKeyNotLoaded in log.

So it will work with: joplin --debug --log-level debug e2ee --retry-failed-items decrypt that will re-prompt for password.

from https://github.com/laurent22/joplin/issues/2981

The error in title of this issue doesn't appear after above command finished.

This error seems to be not catched exception (instead of saying that there is no password for master key for example.)

(I will keep this issue opened to notify laurent about this)

laurent22 commented 4 years ago

no version number? no log?

ambrt commented 4 years ago

no version number? no log?

Sorry for mess, i was a bit tired and its first time i work with joplin logs.

So basically what i think happened is combination of empty password and CTRL+C while trying to recall password from my memory.

EDIT: Below is just what you did in commit.

I never got invalid password warn from https://github.com/laurent22/joplin/blob/fe41d37f8fe226172ae52fbfc9404f09d388bf58/ReactNativeClient/lib/services/EncryptionService.js#L112 so i guess this combination somehow mixed checking for pass.

For the error Cannot read property 'decryptedItemCount' of undefined:

result doesn't get defined, because it conflicts with already active worker: ("DecryptionWorker: cannot start because state is "started"" in log)

https://github.com/laurent22/joplin/blob/3d8577a689167bc8c96f48bb439fcdbe5309b277/CliClient/app/command-e2ee.js#L45-L66

And DecryptionWorker.instance().start() has only one way of going further - when worker is idle.

https://github.com/laurent22/joplin/blob/3d8577a689167bc8c96f48bb439fcdbe5309b277/ReactNativeClient/lib/services/DecryptionWorker.js#L108-L111

So:

When worker is not idle DecryptionWorker.instance().start() returns with undefined, that is assigned to result so when there is attempt to access property "result.decryptedItemCount" it throws uncaught error which breaks the while loop instead of reprompting for password.

Since I don't know why worker didn't go idle, the case here that can be improved is catching error after re-typing of "e2ee decrypt" while decryption worker is already started.

Anyway, its edge case so NP in putting it for other time.

The part of the log is below.

joplin 1.3.3 (prod)

2020-10-29 20:42:41: "Handle: folderList: DOWN", "false"
2020-10-29 20:42:41: "Handle: noteList: DOWN", "false"
2020-10-29 20:42:41: "Handle: noteText: DOWN", "false"
2020-10-29 20:42:41: "Handle: noteMetadata: DOWN", "false"
2020-10-29 20:42:41: "Handle: noteLayout: DOWN", "false"
2020-10-29 20:42:41: "Handle: hLayout: DOWN", "false"
2020-10-29 20:42:41: "Handle: console: DOWN", "true"
2020-10-29 20:42:41: "Handle: statusBar: DOWN", "false"
2020-10-29 20:42:41: "Handle: vLayout: DOWN", "false"
2020-10-29 20:42:41: "Handle: mainWindow: DOWN", "false"
2020-10-29 20:42:41: "Handle: root: DOWN", "null"
2020-10-29 20:45:09: "RevisionService::maintenance: Starting..."
2020-10-29 20:45:09: "RevisionService::maintenance: Service is enabled"
2020-10-29 20:45:09: "RevisionService::collectRevisions: Created revisions for 0 notes"
2020-10-29 20:45:10: "RevisionService::maintenance: Done in 475ms"
2020-10-29 20:45:36: "Running background sync on timer..."
2020-10-29 20:45:36: "Scheduling sync operation...", "0"
2020-10-29 20:45:36: "Preparing scheduled sync"
2020-10-29 20:45:36: "Starting scheduled sync"
2020-10-29 20:45:36: "Sync: starting: Starting synchronisation to target 7... [1604000736180]"
2020-10-29 20:45:36: "get info.json"
2020-10-29 20:45:36: "Sync target info:", "{"version":2}"
2020-10-29 20:45:36: "list "
2020-10-29 20:45:36: "list "
2020-10-29 20:45:37: "put temp/timeCheck480345.txt", "null"
2020-10-29 20:45:38: "stat temp/timeCheck480345.txt"
2020-10-29 20:45:38: "delete temp/timeCheck480345.txt"
2020-10-29 20:45:38: "put locks/sync_cli_6097b2b0b23243bdb6771b76999d2f54.json", "null"
2020-10-29 20:45:39: "list "
2020-10-29 20:45:39: "list "
2020-10-29 20:45:42: "TaskQueue.stop: syncDownload: waiting for tasks to complete: 0"
2020-10-29 20:45:42: "TaskQueue.stop: syncDownload: Done, waited for 0"
2020-10-29 20:45:42: "delta "
2020-10-29 20:45:42: "Sync: fetchingTotal: Fetching delta items from sync target"
2020-10-29 20:45:43: "delete locks/sync_cli_6097b2b0b23243bdb6771b76999d2f54.json"
2020-10-29 20:45:43: "Sync: finished: Synchronisation finished [1604000736180]"
2020-10-29 20:45:43: "Operations completed: "
2020-10-29 20:45:43: "fetchingTotal: -"
2020-10-29 20:45:44: "Total folders: 23"
2020-10-29 20:45:44: "Total notes: 2091"
2020-10-29 20:45:44: "Total resources: 110"
2020-10-29 20:45:44: "Setting up recurrent sync with interval 300"
2020-10-29 20:45:45: "DecryptionWorker: cannot start because state is "started""
2020-10-29 20:46:07: "Shortcut:", ":", "{"keys":[":"],"type":"function","command":"enter_command_line_mode","canRunAlongOtherCommands":false}"
2020-10-29 20:46:48: "Profile directory: /home/user/.config/joplin"
2020-10-29 20:46:48: "KeychainService: checking if keychain supported"
2020-10-29 20:46:48: "KeychainService: check was already done - skipping. Supported:", "0"
2020-10-29 20:46:48: "Client ID: 6097b2b0b23243bdb6771b76999d2f54"
2020-10-29 20:46:48: "Trying to load 3 master keys..."
2020-10-29 20:46:49: "Loaded master keys: 2"
2020-10-29 20:46:49: "ResourceFetcher: Auto-add resources: Mode: always"
2020-10-29 20:46:49: "ResourceFetcher: Auto-added resources: 0"
2020-10-29 20:46:49: "DecryptionWorker: starting decryption..."
2020-10-29 20:46:49: "DecryptionWorker:", "Error: Master key is not loaded: a78dc9f3791b4d508df239a982a39d03
Code: masterKeyNotLoaded
Error: Master key is not loaded: a78dc9f3791b4d508df239a982a39d03
    at EncryptionService.loadedMasterKey (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/EncryptionService.js:172:18)
    at EncryptionService.decryptAbstract_ (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/EncryptionService.js:454:35)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async EncryptionService.decryptString (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/EncryptionService.js:537:3)
    at async Function.decrypt (/home/user/.joplin-bin/lib/node_modules/joplin/lib/models/BaseItem.js:391:21)
    at async DecryptionWorker.start_ (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/DecryptionWorker.js:182:29)
    at async DecryptionWorker.start (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/DecryptionWorker.js:274:13)
    at async startDecryption (/home/user/.joplin-bin/lib/node_modules/joplin/command-e2ee.js:51:21)
    at async Command.action (/home/user/.joplin-bin/lib/node_modules/joplin/command-e2ee.js:101:5)
    at async Application.execCommand (/home/user/.joplin-bin/lib/node_modules/joplin/app.js:305:4)"
2020-10-29 20:46:59: "SearchEngine: Updating FTS table..."
2020-10-29 20:46:59: "SearchEngine: Updated FTS table in 3ms. Inserted: 0. Deleted: 0"
2020-10-29 20:47:03: "Profile directory: /home/user/.config/joplin"
2020-10-29 20:47:03: "KeychainService: checking if keychain supported"
2020-10-29 20:47:03: "KeychainService: check was already done - skipping. Supported:", "0"
2020-10-29 20:47:03: "Client ID: 6097b2b0b23243bdb6771b76999d2f54"
2020-10-29 20:47:03: "Trying to load 3 master keys..."
2020-10-29 20:47:04: "Loaded master keys: 2"
2020-10-29 20:47:04: "ResourceFetcher: Auto-add resources: Mode: always"
2020-10-29 20:47:04: "ResourceFetcher: Auto-added resources: 0"
2020-10-29 20:47:04: "DecryptionWorker: starting decryption..."
2020-10-29 20:47:04: "DecryptionWorker:", "Error: Master key is not loaded: a78dc9f3791b4d508df239a982a39d03
Code: masterKeyNotLoaded
Error: Master key is not loaded: a78dc9f3791b4d508df239a982a39d03
    at EncryptionService.loadedMasterKey (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/EncryptionService.js:172:18)
    at EncryptionService.decryptAbstract_ (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/EncryptionService.js:454:35)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async EncryptionService.decryptString (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/EncryptionService.js:537:3)
    at async Function.decrypt (/home/user/.joplin-bin/lib/node_modules/joplin/lib/models/BaseItem.js:391:21)
    at async DecryptionWorker.start_ (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/DecryptionWorker.js:182:29)
    at async DecryptionWorker.start (/home/user/.joplin-bin/lib/node_modules/joplin/lib/services/DecryptionWorker.js:274:13)
    at async startDecryption (/home/user/.joplin-bin/lib/node_modules/joplin/command-e2ee.js:51:21)
    at async Command.action (/home/user/.joplin-bin/lib/node_modules/joplin/command-e2ee.js:101:5)
    at async Application.execCommand (/home/user/.joplin-bin/lib/node_modules/joplin/app.js:305:4)"