Skip to content

Pub/Sub onMessage data is undefined  #1726

Description

@lafama

Environment details

  • OS: Mac OS
  • Node.js version: 6.8.1
  • npm version:3.8.10
  • google-cloud-node version:0.42.2

Steps to reproduce

  1. require google-cloud
var pubsub = gcloud.pubsub;
var topic = pubsubClient.topic('my-topic');
topic.subscribe('subscription-name', options, function(err, subscription) {
  subscription.on('message', function(message){
    console.log(message.data) //message.data = Contents of the message. is undefined and all the data contents are in the message variable 
  });
});

Example (content of the message, the item_id,body and to are supposed to be under data) according to https://github.com/GoogleCloudPlatform/google-cloud-node/blob/v0.42.2/packages/pubsub/src/subscription.js#L142

ackId=RUXMjY, id=966xxxx, item_id=574, body=xxxx test, to=xxxx87832, , ack=function () { [native code] }, skip=function () {
    delete self.inProgressAckIds[message.ackId];
    self.refreshPausedStatus_();
  }

Activity

  1. lafama commented on Oct 19, 2016

    @lafama
    Author

    Got it fixed. Was a problem with my code

  2. stephenplusplus commented on Oct 19, 2016

    @stephenplusplus
    Contributor

    Phew!

  3. added a commit that references this issue on Mar 11, 2026
  4. added a commit that references this issue on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions