question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation - Is function .publish() deprecated or not?

See original GitHub issue

All the documentation “quick start” examples are showing usage with .publish() function. https://googleapis.dev/nodejs/pubsub/latest/index.html

// Send a message to the topic
  topic.publish(Buffer.from('Test message!'));

https://cloud.google.com/pubsub/docs/quickstart-client-libraries

  try {
    const messageId = await pubSubClient.topic(topicName).publish(dataBuffer);
    console.log(`Message ${messageId} published.`);
  } catch (error) {
    console.error(`Received error while publishing: ${error.message}`);
    process.exitCode = 1;
  }

However this function is deprecated as per the source code documentation https://github.com/googleapis/nodejs-pubsub/blob/main/src/topic.ts#L635 But this commit has been done 2 years ago? https://github.com/googleapis/nodejs-pubsub/commit/b2f96ffe6c1db93741f40804786f8c294717676b#diff-8533605ceddda0b8f0fcbdc3dc3c443d289c4a50622e5562e069a01e202d8b84R613

At first I thought that the docs are just not updated but than it’s already 2 years? So the question is, are the docs really just not updated and we should rewrite it to publishMessage() to get rid of all the warnings we are getting or is that deprecation warning wrong?

Thanks

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
chronos1nsidecommented, Nov 25, 2021

@EyePulp

@chronos1nside sorry, to adapt your example:

const customAtt: Attributes = { ...metadata };
const outboundMessage = { json: payload, attributes: customAtt };
const message = await client.topic(topicName).publishMessage(outboundMessage);

Thanks! I’m gonna work with that 😄

2reactions
EyePulpcommented, Nov 25, 2021

@chronos1nside sorry, to adapt your example:

const customAtt: Attributes = { ...metadata };
const outboundMessage = { json: payload, attributes: customAtt };
const message = await client.topic(topicName).publishMessage(outboundMessage);

Read more comments on GitHub >

github_iconTop Results From Across the Web

publish - RxJS
function deprecated operator. Contents ... Make source$ hot by applying publish operator, then merge each inner observable into a single one and subscribe....
Read more >
Azure Functions runtime versions overview | Microsoft Learn
Azure Functions supports multiple versions of the runtime. Learn the differences between them and how to choose the one that's right for ...
Read more >
JSDoc Reference - TypeScript: Documentation
When a function, method, or property is deprecated you can let users know by marking it with a /** @deprecated */ JSDoc comment....
Read more >
Deprecations by version - GitLab Docs
The VulnerabilityFindingDismiss GraphQL mutation is being deprecated and will be removed in GitLab 16.0. This mutation was not used often as the Vulnerability ......
Read more >
Package google.pubsub.v1 | Cloud Pub/Sub Documentation
It must not be populated by the publisher in a Publish call. ... must have permission to Acknowledge() messages on this subscription.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found