diff --git a/server.js b/server.js index 09ebf16..1d6a024 100644 --- a/server.js +++ b/server.js @@ -10,8 +10,7 @@ const CFG_PATH = path.join(PATH, 'config'); (async () => { const config = await new Config(CFG_PATH); - const { sections } = config; - const count = sections.server.ports.length; + const count = config.sections.server.ports.length; const workers = new Array(count); const start = id => { diff --git a/static/metacom.js b/static/metacom.js index afc5807..e5500b7 100644 --- a/static/metacom.js +++ b/static/metacom.js @@ -9,7 +9,9 @@ export class Metacom { const packet = JSON.parse(data); const { callback, event } = packet; const callId = callback || event; - const [resolve, reject] = this.calls.get(callId); + const promised = this.calls.get(callId); + if (!promised) return; + const [resolve, reject] = promised; if (packet.error) { const { code, message } = packet.error; const error = new Error(message); @@ -39,9 +41,8 @@ export class Metacom { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(packet), }).then(res => { - const { status } = res; - if (status === 200) return res.json().then(({ result }) => result); - throw new Error(`Status Code: ${status}`); + if (res.status === 200) return res.json().then(({ result }) => result); + throw new Error(`Status Code: ${res.status}`); }); }; }