@knowlearning/agents 0.9.83 → 0.9.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ export default options => {
18
18
  this.close = () => ws.close()
19
19
 
20
20
  ws.onopen = () => this.onopen()
21
- ws.onmessage = ({ data }) => this.onmessage(data)
21
+ ws.onmessage = ({ data }) => this.onmessage(data.length === 0 ? null : JSON.parse(data))
22
22
  ws.onerror = error => this.onerror && this.onerror(error)
23
23
  ws.onclose = error => this.onclose && this.onclose(error)
24
24
 
@@ -124,13 +124,12 @@ export default function messageQueue({ token, Connection, watchers, states, appl
124
124
  connection.send({ token: await token(), session })
125
125
  }
126
126
 
127
- connection.onmessage = async data => {
127
+ connection.onmessage = async message => {
128
128
  checkHeartbeat()
129
- if (data.length === 0) return // heartbeat
129
+ if (!message) return // heartbeat
130
130
 
131
131
  try {
132
132
  log('handling message', disconnected, authed)
133
- const message = JSON.parse(data)
134
133
  log('message', JSON.stringify(message))
135
134
 
136
135
  if (message.error) console.warn('ERROR RESPONSE', message)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.83",
3
+ "version": "0.9.84",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",