diff --git a/background.html b/background.html
index cc72737c9..0d4888b77 100644
--- a/background.html
+++ b/background.html
@@ -148,7 +148,7 @@
-
+
diff --git a/js/models/messages.js b/js/models/messages.js
index d04b78608..e3f568e7f 100644
--- a/js/models/messages.js
+++ b/js/models/messages.js
@@ -846,7 +846,8 @@
e.name === 'OutgoingMessageError' ||
e.name === 'SendMessageNetworkError' ||
e.name === 'SignedPreKeyRotationError' ||
- e.name === 'OutgoingIdentityKeyError'
+ e.name === 'OutgoingIdentityKeyError' ||
+ e.name === 'PoWError'
);
},
diff --git a/js/modules/util_worker_interface.js b/js/modules/util_worker_interface.js
index 1c7795887..79306516b 100644
--- a/js/modules/util_worker_interface.js
+++ b/js/modules/util_worker_interface.js
@@ -15,8 +15,9 @@ class TimedOutError extends Error {
}
class WorkerInterface {
- constructor(path) {
+ constructor(path, timeout = WORKER_TIMEOUT) {
this._utilWorker = new Worker(path);
+ this.timeout = timeout;
this._jobs = Object.create(null);
this._DEBUG = false;
this._jobCounter = 0;
@@ -112,7 +113,7 @@ class WorkerInterface {
setTimeout(
() => reject(new TimedOutError(`Worker job ${jobId} (${fnName}) timed out`)),
- WORKER_TIMEOUT
+ this.timeout
);
});
};
diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js
index 9855f9d36..03e487a16 100644
--- a/js/views/conversation_view.js
+++ b/js/views/conversation_view.js
@@ -1623,7 +1623,10 @@
}
const input = this.$messageField;
- const message = window.Signal.Emoji.replaceColons(input.val()).trim();
+ const inputMessage = window.Signal.Emoji.replaceColons(input.val()).trim();
+
+ // Limit the message to 2000 characters
+ const message = inputMessage.substring(0, Math.min(2000, inputMessage.length));
try {
if (!message.length && !this.fileInput.hasFiles()) {
diff --git a/libtextsecure/errors.js b/libtextsecure/errors.js
index 66cf29392..f98b28b61 100644
--- a/libtextsecure/errors.js
+++ b/libtextsecure/errors.js
@@ -127,6 +127,21 @@
}
inherit(Error, UnregisteredUserError);
+ function PoWError(number, error) {
+ // eslint-disable-next-line prefer-destructuring
+ this.number = number.split('.')[0];
+
+ ReplayableError.call(this, {
+ name: 'PoWError',
+ message: 'Failed to calculate PoW',
+ });
+
+ if (error) {
+ appendStack(this, error);
+ }
+ }
+ inherit(ReplayableError, PoWError);
+
window.textsecure.UnregisteredUserError = UnregisteredUserError;
window.textsecure.SendMessageNetworkError = SendMessageNetworkError;
window.textsecure.IncomingIdentityKeyError = IncomingIdentityKeyError;
@@ -135,4 +150,5 @@
window.textsecure.OutgoingMessageError = OutgoingMessageError;
window.textsecure.MessageError = MessageError;
window.textsecure.SignedPreKeyRotationError = SignedPreKeyRotationError;
+ window.textsecure.PoWError = PoWError;
})();
diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js
index e949059b9..9e702a906 100644
--- a/libtextsecure/outgoing_message.js
+++ b/libtextsecure/outgoing_message.js
@@ -195,6 +195,8 @@ OutgoingMessage.prototype = {
throw new textsecure.UnregisteredUserError(number, e);
}
throw new textsecure.SendMessageNetworkError(number, '', e, timestamp);
+ } else if (e.name === 'TimedOutError') {
+ throw new textsecure.PoWError(number, e);
}
throw e;
}
diff --git a/libtextsecure/task_with_timeout.js b/libtextsecure/task_with_timeout.js
index 119d03f11..e0c96ef9e 100644
--- a/libtextsecure/task_with_timeout.js
+++ b/libtextsecure/task_with_timeout.js
@@ -7,7 +7,7 @@
window.textsecure = window.textsecure || {};
window.textsecure.createTaskWithTimeout = (task, id, options = {}) => {
- const timeout = options.timeout || 1000 * 60 * 2; // two minutes
+ const timeout = options.timeout || 1000 * 60 * 3; // three minutes
const errorForStack = new Error('for stack');
return () =>
diff --git a/preload.js b/preload.js
index d6b8924b3..e6942138a 100644
--- a/preload.js
+++ b/preload.js
@@ -269,8 +269,9 @@ window.LokiAPI = new LokiServer({
window.mnemonic = require('./libloki/mnemonic');
const { WorkerInterface } = require('./js/modules/util_worker_interface');
+// A Worker with a 3 minute timeout
const utilWorkerPath = path.join(app.getAppPath(), 'js', 'util_worker.js');
-const utilWorker = new WorkerInterface(utilWorkerPath);
+const utilWorker = new WorkerInterface(utilWorkerPath, 3 * 60 * 1000);
window.callWorker = (fnName, ...args) => utilWorker.callWorker(fnName, ...args);
// Linux seems to periodically let the event loop stop, so this is a global workaround