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

Typescript: publishMessage wrong response type #1438

@melchek-bot

Description

@melchek-bot

@google-cloud/pubsub version 2.18.3

In topic.d.ts:464

   * Publish the provided message.
   *
   * @throws {TypeError} If data is not a Buffer object.
   * @throws {TypeError} If any value in `attributes` object is not a string.
   *
   * @param {MessageOptions} message Message object.
   * @param {PublishCallback} [callback] Callback function.
   * @returns {Promise<PublishResponse>}
   *
   * @example
   ....
        * @example To publish messages in order (this is still experimental), make sure message ordering is enabled and provide an ordering key
   * ```
   * const topic = pubsub.topic('ordered-topic', {messageOrdering: true});
   * const orderingKey = 'my-key';
   *
   * topic.publishMessage({data, orderingKey}, callback);
   *
   * ```
   * @example If the callback is omitted, we'll return a Promise.
   * ```
   * const [messageId] = await topic.publishMessage({data}); <------ 
   * ```
   * ```
  publishMessage(message: MessageOptions): Promise<[string]>; <-----

Calling const [messageId] = await topic.publishMessage({data});
messageId gets the first character of the id, since publishMessage is returning a string and not an array of strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: pubsubIssues related to the googleapis/nodejs-pubsub API.type: docsImprovement to the documentation for an API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions