-
Notifications
You must be signed in to change notification settings - Fork 235
Description
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Is your feature request related to a problem? Please describe.
In publishMessage method of Topic, it checks if data is instance of Buffer.
Some of modern serialization library uses Uint8Array as return value instead of Buffer. Although we can change it into Buffer using Buffer.from, it will copy Arraybuffer, which causes performance issue.
Since Buffer is subclass of Uint8Array, I think it can be changed into data && !(data instanceof Uint8Array).
Describe the solution you'd like
Change src/publisher/index.ts L195 into if (data && !(data instanceof Uint8Array)) {.
Describe alternatives you've considered
We can change Uint8Array into Buffer using Buffer.frommethod, but it will 'copy' array and create new one.
Additional context
.