@beanstalk/core
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -21,8 +21,16 @@ "use strict"; | ||
ctx.append(chunk); | ||
protocol_1.parse(ctx, messages); | ||
while (messages.length > 0) { | ||
try { | ||
protocol_1.parse(ctx, messages); | ||
while (messages.length > 0) { | ||
const emitter = this._pendingRequests.shift(); | ||
if (emitter) { | ||
const msg = messages.shift(); | ||
emitter.emit('resolve', msg); | ||
} | ||
} | ||
} | ||
catch (err) { | ||
const emitter = this._pendingRequests.shift(); | ||
if (emitter) { | ||
const msg = messages.shift(); | ||
emitter.emit('resolve', msg); | ||
emitter.emit('reject', err); | ||
} | ||
@@ -29,0 +37,0 @@ } |
@@ -14,2 +14,3 @@ /// <reference types="node" /> | ||
update(): void; | ||
clear(): void; | ||
} | ||
@@ -16,0 +17,0 @@ export declare type R<T = any> = { |
@@ -20,4 +20,8 @@ "use strict"; | ||
} | ||
clear() { | ||
this._buf = Buffer.from([]); | ||
this.offset = 0; | ||
} | ||
} | ||
exports.ParseContext = ParseContext; | ||
//# sourceMappingURL=internal_types.js.map |
@@ -5,2 +5,3 @@ "use strict"; | ||
const parse_utils_1 = require("./parse-utils"); | ||
const error_1 = require("./error"); | ||
/** | ||
@@ -265,11 +266,11 @@ * Messages | ||
const start = ctx.offset; | ||
const id = {}; | ||
if (token(ctx, M.RESERVED)) { | ||
if (parse_utils_1.space(ctx)) { | ||
const id = {}; | ||
// <id> | ||
if (parse_utils_1.integer(ctx, id)) { | ||
// <id> | ||
if (parse_utils_1.space(ctx)) { | ||
const len = {}; | ||
// <bytes> | ||
if (parse_utils_1.integer(ctx, len)) { | ||
// <bytes> | ||
if (parse_utils_1.crlf(ctx)) { | ||
@@ -282,6 +283,9 @@ if (ctx.buf.length - ctx.offset >= len.value) { | ||
} | ||
else if (ctx.buf.length - ctx.offset === 2) { | ||
// resilience / dirty hack | ||
ctx.offset += 2; | ||
return true; | ||
else { | ||
let data; | ||
if (id.value) { | ||
data = { id: id.value }; | ||
} | ||
ctx.clear(); | ||
throw new error_1.BeanstalkClientError(`Malformed ${M.RESERVED} response message`, data); | ||
} | ||
@@ -288,0 +292,0 @@ } |
{ | ||
"name": "@beanstalk/core", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "Yet another Beanstalkd client library", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/maxleiko/beanstalk-core", |
80887
2253