Skip to content

Commit c25440e

Browse files
committedOct 18, 2021
revert some failing test
1 parent d72af39 commit c25440e

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed
 

‎lib/channel_model.js

+29-26
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,17 @@ class Channel extends BaseChannel {
158158
return this.publish('', queue, content, options);
159159
}
160160

161-
async consume(queue, callback, options) {
161+
consume(queue, callback, options) {
162162
// NB we want the callback to be run synchronously, so that we've
163163
// registered the consumerTag before any messages can arrive.
164164
const fields = Args.consume(queue, options);
165-
const ok = await Promise.fromCallback(cb => {
165+
return Promise.fromCallback(cb => {
166166
this._rpc(defs.BasicConsume, fields, defs.BasicConsumeOk, cb);
167167
})
168-
169-
this.registerConsumer(ok.fields.consumerTag, callback);
170-
return ok.fields;
168+
.then(ok => {
169+
this.registerConsumer(ok.fields.consumerTag, callback);
170+
return ok.fields;
171+
});
171172
}
172173

173174
async cancel(consumerTag) {
@@ -176,32 +177,34 @@ class Channel extends BaseChannel {
176177
defs.BasicCancelOk,
177178
cb);
178179
})
179-
180-
this.unregisterConsumer(consumerTag);
181-
return ok.fields;
180+
.then(ok => {
181+
this.unregisterConsumer(consumerTag);
182+
return ok.fields;
183+
});
182184
}
183185

184-
async get(queue, options) {
186+
get(queue, options) {
185187
const fields = Args.get(queue, options);
186-
const f = await Promise.fromCallback(cb => {
187-
this.sendOrEnqueue(defs.BasicGet, fields, cb);
188+
return Promise.fromCallback(cb => {
189+
return this.sendOrEnqueue(defs.BasicGet, fields, cb);
188190
})
189-
190-
if (f.id === defs.BasicGetEmpty) {
191-
return false;
192-
}
193-
else if (f.id === defs.BasicGetOk) {
194-
const fields = f.fields;
195-
return new Promise(resolve => {
196-
this.handleMessage = acceptMessage(m => {
197-
m.fields = fields;
198-
resolve(m);
191+
.then(f => {
192+
if (f.id === defs.BasicGetEmpty) {
193+
return false;
194+
}
195+
else if (f.id === defs.BasicGetOk) {
196+
const fields = f.fields;
197+
return new Promise(resolve => {
198+
this.handleMessage = acceptMessage(m => {
199+
m.fields = fields;
200+
resolve(m);
201+
});
199202
});
200-
});
201-
}
202-
else {
203-
throw new Error(`Unexpected response to BasicGet: ${inspect(f)}`);
204-
}
203+
}
204+
else {
205+
throw new Error(`Unexpected response to BasicGet: ${inspect(f)}`);
206+
}
207+
});
205208
}
206209

207210
ack(message, allUpTo) {

0 commit comments

Comments
 (0)
Please sign in to comment.