1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Improved network error handling

This commit is contained in:
Laurent Cozic 2017-10-15 12:13:09 +01:00
parent 65ab55c031
commit 3d8327ae0b
7 changed files with 350 additions and 349 deletions

View File

@ -29,7 +29,8 @@ fi
PACKAGE_MD5=$(cat "$ROOT_DIR/package.json.md5")
MAIN_PATH="$ROOT_DIR/build/main.js"
LINE_TO_ADD="var osTmpdir = require('os-tmpdir'); process.env.CACHE_REQUIRE_PATHS_FILE = osTmpdir() + '/joplin-module-path-cache-$PACKAGE_MD5'; require('cache-require-paths'); require('app-module-path').addPath(__dirname);"
#LINE_TO_ADD="var osTmpdir = require('os-tmpdir'); process.env.CACHE_REQUIRE_PATHS_FILE = osTmpdir() + '/joplin-module-path-cache-$PACKAGE_MD5'; require('cache-require-paths'); require('app-module-path').addPath(__dirname);"
LINE_TO_ADD="require('app-module-path').addPath(__dirname);"
RESULT="$(grep "$LINE_TO_ADD" "$MAIN_PATH")"
if [[ -z "$RESULT" ]]; then
echo "Adding extra modules..."

View File

@ -1,7 +1,10 @@
#!/bin/bash
set -e
CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
npm version patch
$CLIENT_DIR/build.sh
sudo rsync -aP "$CLIENT_DIR/build/" "/usr/lib/node_modules/joplin/"
"$CLIENT_DIR/publish.sh"
npm update -g joplin
# npm version patch
# $CLIENT_DIR/build.sh
# sudo rsync -aP "$CLIENT_DIR/build/" "/usr/lib/node_modules/joplin/"

View File

@ -7,7 +7,7 @@
"url": "https://github.com/laurent22/joplin"
},
"url": "git://github.com/laurent22/joplin.git",
"version": "0.9.19",
"version": "0.10.30",
"bin": {
"joplin": "./main.js"
},

View File

@ -1 +1 @@
6992ebc000d140ce3115945ff128ac7b
f4b153177f47463d4e54b97430d0ae63

File diff suppressed because it is too large Load Diff

View File

@ -158,6 +158,8 @@ class OneDriveApi {
if (data) options.body = data;
options.timeout = 1000 * 60 * 5; // in ms
for (let i = 0; i < 5; i++) {
options.headers['Authorization'] = 'bearer ' + this.token();
@ -171,13 +173,25 @@ class OneDriveApi {
response = await shim.fetchBlob(url, options);
}
} catch (error) {
let canRetry = true;
if (error.message == 'Network request failed') {
// Unfortunately the error 'Network request failed' doesn't have a type
// or error code, so hopefully that message won't change and is not localized
this.logger().info('Got error "Network request failed" - retrying (' + i + ')...');
} else if (error.code == 'ECONNRESET') {
// request to https://public-ch3302....1fab24cb1bd5f.md failed, reason: socket hang up"
} else if (error.message.indexOf('network timeout') === 0) {
// network timeout at: https://public-ch3302...859f9b0e3ab.md
} else {
canRetry = false;
}
if (canRetry) {
this.logger().info('Got error code ' + error.code + ': ' + error.message + ' - retrying (' + i + ')...');
await time.sleep((i + 1) * 3);
continue;
} else {
this.logger().error('Got unhandled error:', error ? error.code : '', error ? error.message : '', error);
throw error;
}
}

View File

@ -8,8 +8,15 @@ function shimInit() {
shim.fs = fs;
shim.FileApiDriverLocal = FileApiDriverLocal;
shim.Geolocation = GeolocationNode;
shim.fetch = require('node-fetch');
shim.FormData = require('form-data');
const nodeFetch = require('node-fetch');
shim.fetch = function(url, options = null) {
if (!options) options = {};
if (!options.timeout) options.timeout = 1000 * 120; // ms
return nodeFetch(url, options);
}
shim.fetchBlob = async function(url, options) {
if (!options || !options.path) throw new Error('fetchBlob: target file path is missing');