@schukai/monster 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schukai/monster",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -231,14 +231,15 @@ class WebSocketDatasource extends Datasource {
231
231
 
232
232
  /**
233
233
  * @return {Promise}
234
- * @throws {Error} the options does not contain a valid json definition
235
- * @throws {Error} the data cannot be read
236
- * @throws {TypeError} value is not an object
237
234
  */
238
235
  read() {
239
236
  const self = this;
240
237
  let response;
241
238
 
239
+ if (self[connectionSymbol]?.socket?.readyState!==1) {
240
+ return Promise.reject('The connection is not established.');
241
+ }
242
+
242
243
  return new Promise((resolve, reject) => {
243
244
  if (self[receiveQueueSymbol].isEmpty()) {
244
245
  resolve();
@@ -290,6 +291,10 @@ class WebSocketDatasource extends Datasource {
290
291
  */
291
292
  write() {
292
293
  const self = this;
294
+
295
+ if (self[connectionSymbol]?.socket?.readyState!==1) {
296
+ return Promise.reject('The connection is not established.');
297
+ }
293
298
 
294
299
  let obj = self.get();
295
300
  let transformation = self.getOption('write.mapping.transformer');
@@ -149,7 +149,7 @@ function getMonsterVersion() {
149
149
  }
150
150
 
151
151
  /** don't touch, replaced by make with package.json version */
152
- monsterVersion = new Version('3.1.1')
152
+ monsterVersion = new Version('3.1.2')
153
153
 
154
154
  return monsterVersion;
155
155
 
@@ -98,7 +98,8 @@ describe('Websocket', function () {
98
98
  }).catch((err) => {
99
99
  done(new Error(err));
100
100
  })
101
- }, 1000)
101
+ },
102
+ 500)
102
103
 
103
104
 
104
105
  }).timeout(10000);
@@ -7,7 +7,7 @@ describe('Monster', function () {
7
7
  let monsterVersion
8
8
 
9
9
  /** don´t touch, replaced by make with package.json version */
10
- monsterVersion = new Version('3.1.1')
10
+ monsterVersion = new Version('3.1.2')
11
11
 
12
12
  let m = getMonsterVersion();
13
13