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

[storage-blob] processing downloadBlockBlobResponse.readableStreamBody stucks/hangs - and doesn't throw #2 #25780

Closed
4 tasks
PedroFonsecaDEV opened this issue May 7, 2023 · 3 comments
Labels
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

Comments

@PedroFonsecaDEV
Copy link

  • Package Name:
  • Package Version:
  • Operating system:
  • [x ] nodejs
    • version: 16
  • browser
    • name/version:
  • [x ] typescript
    • version: 4.4.4
  • Is the bug related to documentation in

Describe the bug
#16987 should be re-opened.
Error is still happening.

No events or errors occurs, the for await of just pre mature exit the process.
code:

get the readableStream from the download method and then:
 const parser = readableStream.pipe(csvParser());
        for await (const row of parser) {
                console.log(row)
        }

. The best way of reproducing is disconnecting your computer from the network when reading rows from the storage account test with a huge file of at least 500mb.

To Reproduce
Steps to reproduce the behavior:

  1. The best way to reproduce is disconnecting your computer from the network during the process.(500mb file)

Expected behavior
throw an error upon disconnecting.
Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels May 7, 2023
@EmmaZhu
Copy link
Member

EmmaZhu commented May 8, 2023

Hi @PedroFonsecaDEV ,

Current retry only happens when it meets error before or during getting the response headers. If the network failure happens when downloading the response body, neither of timeout or retry logic would work.

Besides that, it's not recommend downloading a large file with only one download operation. It'd be more robust to split a large blob to small pieces, and download each piece with one download call.

Following is a sample shows how to split a large to small piece. Please be noted, it's only a sample without fully test, it's just used to show you the possible workaround logic. Please do make fully validation before using it in your production.


const fd = await fs.open(path, 'w');

  const propertes = await blockBlobClient.getProperties();
  const buffer = Buffer.alloc(4 * 1024 * 1024);
  const count = 4194304;

  for (let offset = 0; offset < propertes.contentLength!;){
    const downloadCount = Math.min(propertes.contentLength! - offset, count);
    offset += downloadCount;
    let retryMax = 3;
    let shouldRetry = true;

    while (retryMax >= 0 && shouldRetry) {
      try {
        await blockBlobClient.downloadToBuffer(buffer, offset, downloadCount, {
          abortSignal: AbortController.timeout(10 *1000), // Abort uploading with timeout in 10 secs
          blockSize: 4 * 1024 * 1024, // 4MB block size
          onProgress: (ev) => console.log(ev),
        });
        shouldRetry = false;
        console.log("downloadToBuffer succeeds");
      } catch (err: any) {
        shouldRetry = true;
      }
      --retryMax;
    }

    // shouldRetry is false, means that download succeeded.
    if (!shouldRetry) {
      await fd.write(buffer, 0, downloadCount, offset);
    }
  }

  await fd.close();

Thanks
Emma

@EmmaZhu EmmaZhu added the needs-author-feedback Workflow: More information is needed from author to address the issue. label May 8, 2023
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label May 8, 2023
@github-actions
Copy link

github-actions bot commented May 8, 2023

Hi @PedroFonsecaDEV. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@github-actions
Copy link

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

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue. label May 15, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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
Projects
None yet
Development

No branches or pull requests

2 participants