Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Service Bus] Long is undefined after updating the long npm package from 4.0 to 5.2. #24168

Closed
2 of 6 tasks
abouroubi opened this issue Dec 8, 2022 · 2 comments
Closed
2 of 6 tasks
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus

Comments

@abouroubi
Copy link
Contributor

abouroubi commented Dec 8, 2022

  • Package Name: @azure/service-bus
  • Package Version: 7.7.3
  • Operating system: Linux/MacOS
  • nodejs
    • version: 18.12.1
  • browser
    • name/version:
  • typescript
    • version: 4.8.4
  • Is the bug related to documentation in

Describe the bug
There is an issue with the latest version of long, and it made the service-bus SDK unusable...
dcodeIO/long.js#109

Following the discussion started in #21208 (comment)

To Reproduce
Steps to reproduce the behavior:

  1. import Long from 'long' package
  2. Use Long.fromString() function to convert a string message id to long to be able to use it with the Service Bus SDK.
  3. The app will crash with this error: TypeError: Cannot read properties of undefined (reading 'fromString')

Expected behavior
The conversion of string to Long to happen without issues.

Additional context
Here is the code used:

import {
  ProcessErrorArgs,
  ServiceBusClient,
  ServiceBusMessage,
  ServiceBusReceivedMessage,
  ServiceBusReceiver,
  ServiceBusSender,
} from '@azure/service-bus';
import Long from 'long';


export class QueueService {

  private sbClient: ServiceBusClient;
  private sender: ServiceBusSender;
  private receiver: ServiceBusReceiver;

  constructor() {
    this.sbClient = new ServiceBusClient("[ConnectionString]");
    this.sender = this.sbClient.createSender("[QueueName]");
    this.receiver = this.sbClient.createReceiver("[QueueName]");
  }

  async sendMessage(body: any, scheduledEnqueueTimeUtc: Date): Promise<string> {
    const message: ServiceBusMessage = {
      body: body,
    };
    const results = await this.sender.scheduleMessages(message, scheduledEnqueueTimeUtc);

    return results[0].toString();
  }

  async cancelMessage(messageId: string) {
    this.sender.cancelScheduledMessages(Long.fromString(messageId));
  }

  async receiveMessages(
    processMessage: (message: { id: string; content: string }) => Promise<void>,
    processError: () => Promise<void>,
  ) {
    const process = async (brokeredMessage: ServiceBusReceivedMessage) => {
      await processMessage(brokeredMessage.body);
      await this.receiver.completeMessage(brokeredMessage);
    };
    const error = async (args: ProcessErrorArgs) => {
      await processError();
    };

    this.receiver.subscribe(
      {
        processMessage: process,
        processError: error,
      },
      {
        autoCompleteMessages: false,
      },
    );
  }
}
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 8, 2022
@azure-sdk azure-sdk added Client This issue points to a problem in the data-plane of the library. needs-team-triage Workflow: This issue needs the team to triage. Service Bus labels Dec 8, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 8, 2022
@xirzec xirzec removed the needs-team-triage Workflow: This issue needs the team to triage. label Dec 8, 2022
jeremymeng added a commit to jeremymeng/js-24168 that referenced this issue Dec 14, 2022
@jeremymeng
Copy link
Member

@abouroubi Thanks for sharing the repo code! I gave it a try with slight modification in a standard TypeScript project and it worked as expected for me. I don't see any errors. Here's the list of my commits: https://github.com/jeremymeng/js-24168/commits/master

Could you please take a look, and let me know what I might be missing, comparing to your environment?

@jeremymeng jeremymeng added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Dec 15, 2022
@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Dec 22, 2022
@ghost
Copy link

ghost commented Dec 22, 2022

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@ghost ghost closed this as completed Jan 7, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Projects
None yet
Development

No branches or pull requests

4 participants