laurent22 / joplin

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

OneDrive sync issues #8561

Closed Viald closed 11 months ago

Viald commented 1 year ago

I use Microsoft OneDrive to sync 2 windows laptops and 1 android device. Encryption is enabled.

For all devices the synchronisation fails randomly with always the same error message: TypeError: On file ad59f2174a8c411b8d41d97cd6ee959b.md: Cannot read properties of undefined (reading 'retry-after')

This error is not always on the same .md file. For each one, I have checked it directly on OneDrive without issue.

Environment

Joplin version: Joplin 2.11.11 (prod, win32) Révision : 6886f6f Platform: Windows 10 64bit and Android 11

Logfile

... 2023-07-26 18:56:17: Synchronizer: "Sync: fetchingProcessed: Processing fetched item" 2023-07-26 18:56:17: Synchronizer: "Sync: fetchingProcessed: Processing fetched item" 2023-07-26 18:56:18: Synchronizer: "BasicDelta: Report: {"timestamp":1690383254000,"older":1699,"newer":39,"equal":1}" 2023-07-26 18:56:18: Synchronizer: "Sync: fetchingTotal: Fetching delta items from sync target" 2023-07-26 18:56:18: Synchronizer: "Sync: fetchingProcessed: Processing fetched item" 2023-07-26 18:56:18: Synchronizer: "Sync: fetchingProcessed: Processing fetched item" 2023-07-26 18:56:18: Synchronizer: "TypeError: On file ad59f2174a8c411b8d41d97cd6ee959b.md: Cannot read properties of undefined (reading 'retry-after') TypeError: On file ad59f2174a8c411b8d41d97cd6ee959b.md: Cannot read properties of undefined (reading 'retry-after') at OneDriveApi. (C:\Users\me\AppData\Local\Programs\Joplin\resources\app.asar\node_modules\@joplin\lib\onedrive-api.js:339:244) at Generator.next () at fulfilled (C:\Users\me\AppData\Local\Programs\Joplin\resources\app.asar\node_modules\@joplin\lib\onedrive-api.js:5:58) at process.processTicksAndRejections (node:internal/process/task_queues:96:5)" 2023-07-26 18:56:18: Synchronizer: "Sync: finished: Synchronisation finished [1690390365688]" 2023-07-26 18:56:18: Synchronizer: "Operations completed: " 2023-07-26 18:56:18: Synchronizer: "fetchingTotal: 1762" 2023-07-26 18:56:18: Synchronizer: "fetchingProcessed: 1714" 2023-07-26 18:56:18: Synchronizer: "deleteLocal: 1" 2023-07-26 18:56:18: Synchronizer: "Total folders: 203" 2023-07-26 18:56:18: Synchronizer: "Total notes: 1147" 2023-07-26 18:56:18: Synchronizer: "Total resources: 478" 2023-07-26 18:56:18: Synchronizer: "There was some errors:" 2023-07-26 18:56:18: Synchronizer: "TypeError: On file ad59f2174a8c411b8d41d97cd6ee959b.md: Cannot read properties of undefined (reading 'retry-after') TypeError: On file ad59f2174a8c411b8d41d97cd6ee959b.md: Cannot read properties of undefined (reading 'retry-after') at OneDriveApi. (C:\Users\me\AppData\Local\Programs\Joplin\resources\app.asar\node_modules\@joplin\lib\onedrive-api.js:339:244) at Generator.next () at fulfilled (C:\Users\me\AppData\Local\Programs\Joplin\resources\app.asar\node_modules\@joplin\lib\onedrive-api.js:5:58) at process.processTicksAndRejections (node:internal/process/task_queues:96:5)" 2023-07-26 18:56:18: "Sync has finished and note has never been changed - reloading it" 2023-07-26 18:56:19: "DecryptionWorker: starting decryption..." 2023-07-26 18:56:19: "DecryptionWorker: completed decryption."

Viald commented 1 year ago

Below logs when the sync is complete: ... 2023-07-26 19:30:49: Synchronizer: "Sync: fetchingProcessed: Processing fetched item" 2023-07-26 19:30:49: Synchronizer: "Sync: fetchingProcessed: Processing fetched item" 2023-07-26 19:30:50: Synchronizer: "BasicDelta: Report: {"timestamp":1690392389000,"older":1898,"newer":1,"equal":2}" 2023-07-26 19:30:50: Synchronizer: "Sync: fetchingTotal: Fetching delta items from sync target" 2023-07-26 19:30:50: Synchronizer: "Sync: fetchingProcessed: Processing fetched item" 2023-07-26 19:30:50: Synchronizer: "Sync: fetchingProcessed: Processing fetched item" 2023-07-26 19:30:51: Synchronizer: "Sync: finished: Synchronisation finished [1690392385890]" 2023-07-26 19:30:51: Synchronizer: "Operations completed: " 2023-07-26 19:30:51: Synchronizer: "createRemote: 6" 2023-07-26 19:30:51: Synchronizer: "fetchingTotal: 1914" 2023-07-26 19:30:51: Synchronizer: "fetchingProcessed: 1914" 2023-07-26 19:30:51: Synchronizer: "deleteLocal: 1" 2023-07-26 19:30:51: Synchronizer: "Total folders: 202" 2023-07-26 19:30:51: Synchronizer: "Total notes: 1148" 2023-07-26 19:30:51: Synchronizer: "Total resources: 478" 2023-07-26 19:30:51: "Sync has finished and note has never been changed - reloading it" 2023-07-26 19:30:52: "DecryptionWorker: starting decryption..." 2023-07-26 19:30:52: "DecryptionWorker: completed decryption." 2023-07-26 19:31:00: "SearchEngine: Updating FTS table..." 2023-07-26 19:31:00: "SearchEngine: Updated FTS table in 2ms. Inserted: 0. Deleted: 0"

personalizedrefrigerator commented 1 year ago

From the documentation, retry-after might need to be changed to Retry-After: https://github.com/laurent22/joplin/blob/06732d8b8aaa7ca9edbe25970c34c72f184f9c27/packages/lib/onedrive-api.ts#L346-L353

Viald commented 1 year ago

Well considered!

Viald commented 1 year ago

I search in Joplin.exe and find this part of code

// This function is used to help avoid the lowercasing of a field name if it // matches a 'traditional cased' version of a field name. It then returns the // lowercased name to both avoid calling toLowerCase() a second time and to // indicate whether the field was a 'no duplicates' field. If a field is not a // 'no duplicates' field, a 0 byte is prepended as a flag. The one exception // to this is the Set-Cookie header which is indicated by a 1 byte flag, since // it is an 'array' field and thus is treated differently in _addHeaderLines(). // TODO: perhaps http_parser could be returning both raw and lowercased versions // of known header names to avoid us having to call toLowerCase() for those // headers. function matchKnownFields(field, lowercased) { switch (field.length) { case 3: if (field === 'Age' || field === 'age') return 'age'; break; case 4: if (field === 'Host' || field === 'host') return 'host'; if (field === 'From' || field === 'from') return 'from'; if (field === 'ETag' || field === 'etag') return 'etag'; if (field === 'Date' || field === 'date') return '\u0000date'; if (field === 'Vary' || field === 'vary') return '\u0000vary'; break; case 6: if (field === 'Server' || field === 'server') return 'server'; if (field === 'Cookie' || field === 'cookie') return '\u0002cookie'; if (field === 'Origin' || field === 'origin') return '\u0000origin'; if (field === 'Expect' || field === 'expect') return '\u0000expect'; if (field === 'Accept' || field === 'accept') return '\u0000accept'; break; case 7: if (field === 'Referer' || field === 'referer') return 'referer'; if (field === 'Expires' || field === 'expires') return 'expires'; if (field === 'Upgrade' || field === 'upgrade') return '\u0000upgrade'; break; case 8: if (field === 'Location' || field === 'location') return 'location'; if (field === 'If-Match' || field === 'if-match') return '\u0000if-match'; break; case 10: if (field === 'User-Agent' || field === 'user-agent') return 'user-agent'; if (field === 'Set-Cookie' || field === 'set-cookie') return '\u0001'; if (field === 'Connection' || field === 'connection') return '\u0000connection'; break; case 11: if (field === 'Retry-After' || field === 'retry-after') return 'retry-after'; break;

It seems that lowercase is taking into account.

jeronome commented 1 year ago

Hi, I'm new on github and have little idea in programing. But I have a very similar error with Joplin. I use version 2.12.15 with ubuntu. I don't have this problem with Mac and android systems. Any help would be appreciated.

Synchronizer: TypeError: On file cc4c3551c413489d94d7d7dce54e5d2a.md: Cannot read properties of undefined (reading 'retry-after')

at OneDriveApi. (onedrive-api.ts:346:85)

at Generator.next ()

at fulfilled (/snap/joplin-desktop/37/opt/joplin-desktop/resources/app/node_modules/@joplin/lib/onedrive-api.js:5:58)

at` process.processTicksAndRejections (node:internal/process/task_queue

github-actions[bot] commented 1 year ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? If you require support or are requesting an enhancement or feature then please create a topic on the Joplin forum. This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.