2 * How many times failed request is retried before giving up and failing
5 export const MAX_RETRIES_BEFORE_FAIL = 3;
8 * MAX_ENCRYPTED_BLOCKS limits the number of blocks in the buffer before
9 * asking API for next batch of links, if not asked sooner by low buffer
10 * of uploading blocks.
12 export const MAX_ENCRYPTED_BLOCKS = 15;
15 * MAX_UPLOADING_BLOCKS limits the number of blocks in the buffer for
16 * upload. It should be a bit bigger than MAX_UPLOAD_JOBS to ensure that
17 * there is always ready next block when any upload job finishes current
18 * upload. When there is not enough uploading jobs, worker asks for link
19 * creation sooner than it hits the ideal size of MAX_ENCRYPTED_BLOCKS.
21 export const MAX_UPLOADING_BLOCKS = 10;
24 * MAX_BLOCKS_PER_UPLOAD is how many blocks can one upload job have buffered
25 * in memory. Used to count the current load for the total limit of ongoing
26 * upload files by MAX_UPLOAD_BLOCKS_LOAD.
28 export const MAX_BLOCKS_PER_UPLOAD = MAX_ENCRYPTED_BLOCKS + MAX_UPLOADING_BLOCKS;
31 * MAX_UPLOAD_BLOCKS_LOAD limits the number of total blocks being uploaded
32 * at one time. If the queue contains only big files, only few of them at
33 * a time is allowed to limit the memory requirements. If the queue contains
34 * small files, more can be uploaded in parallel. But each upload mean extra
35 * worker. Even though browsers support up to hunderds of web workers, still
38 export const MAX_UPLOAD_BLOCKS_LOAD = 4;
41 * MAX_UPLOAD_FOLDER_LOAD limits the number of total folder being created
44 export const MAX_UPLOAD_FOLDER_LOAD = 5;
47 * How many ongoing uploads there can be. Without http2, we cannot do more
48 * than six parallel requests to one host. With http2 (which we use), there
49 * is theretically no limit, but still we should make a reasonable limit
50 * to not kill users device.
52 export const MAX_UPLOAD_JOBS = 5;
55 * WAIT_TIME is used for pauses between checks, such as to check if buffer is
56 * still full or not, or if the upload is paused, and so on.
58 export const WAIT_TIME = 50; // Milliseconds.
61 * TOKEN_EXPIRATION_TIME defines after what time server expires the token.
62 * We can optimise and not even ask for block upload if we know the token
63 * is already old and we should ask for new one.
65 export const TOKEN_EXPIRATION_TIME = 3 * 60 * 60 * 1000; // Milliseconds.
68 * MAX_TOO_MANY_REQUESTS_WAIT defines how many seconds is allowed to wait
69 * if server rate limits upload. If server asks to wait longer, we don't
70 * wait and fail right away instead.
72 export const MAX_TOO_MANY_REQUESTS_WAIT = 60 * 60; // Seconds.
75 * MAX_BLOCK_VERIFICATION_RETRIES defines how many times we will retry
76 * encrypting a block if it fails verification.
78 * For context, blocks are verified after encryption to check for
79 * corrupted encrypted data. If this fails, we retry creating the block
80 * entirely. The main utility is to mitigate bitflip issues.
82 export const MAX_BLOCK_VERIFICATION_RETRIES = 1;
85 * Amount of time between heartbeats. These are used to ensure the worker
86 * is still alive, and not stuck in a bad state.
88 export const HEARTBEAT_INTERVAL = 30 * 1000; // ms
91 * Amount of time to wait for a new heartbeat. If no heartbeat is received
92 * during this interval, we cancel and restart the worker.
94 * This should be greater than HEARTBEAT_INTERVAL;
96 export const HEARTBEAT_WAIT_TIME = HEARTBEAT_INTERVAL * 2; // ms
99 * Amout of time to wait for messages after initialization before considering
100 * the worker is dead and asking the user to refresh the page.
102 * On Chrome, we have no way to know if a worker fetch was successful.
104 export const WORKER_INIT_WAIT_TIME = 5 * 1000; // ms