Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit eb68ec3

Browse files
error on non buffer arguments to pubsub.publish
1 parent 748cf2e commit eb68ec3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/api/pubsub.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ module.exports = (send) => {
5757
}
5858
},
5959
publish: promisify((topic, data, callback) => {
60-
const buf = Buffer.isBuffer(data) ? data : new Buffer(data)
60+
if (!Buffer.isBuffer(data)) {
61+
return callback(new Error('data must be a Buffer'))
62+
}
6163

6264
const request = {
6365
path: 'pubsub/pub',
64-
args: [topic, buf]
66+
args: [topic, data]
6567
}
6668

6769
send(request, callback)

0 commit comments

Comments
 (0)