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

ms-rest-js throws RestError when requiring @azure/storage-blob components #5279

Closed
1 of 6 tasks
nikodemrafalski opened this issue Sep 27, 2019 · 16 comments
Closed
1 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. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)

Comments

@nikodemrafalski
Copy link

nikodemrafalski commented Sep 27, 2019

  • Package Name@azure/storage-blob:
  • **Package Version10.5.0:
  • **Operating systemWindows:
  • nodejs
    • version: 10.14.1
  • browser
    • name/version:
  • typescript
    • version:
  • Is the bug related to documentation in

Describe the bug
Given line at top of my file causes runtime Error (and process crash) not always - from time to time.
const { Aborter, BlockBlobURL, SharedKeyCredential, StorageURL } = require('@azure/storage-blob');

Exception raised:

{ Error: The request was aborted
    at new RestError (D:\home\site\wwwroot\node_modules\@azure\ms-rest-js\dist\msRest.node.js:2400:28)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\@azure\storage-blob\dist\index.js:1274:19)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at Module.patchedRequire [as require] (D:\home\site\wwwroot\node_modules\diagnostic-channel\dist\src\patchRequire.js:14:46)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (D:\home\site\wwwroot\commands\files\DeleteFileCommand.js:1:130)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
  code: 'REQUEST_ABORTED_ERROR',
  statusCode: undefined,
  request: undefined,
  response: undefined,
  body: undefined,
  domainEmitter:
   RetriableReadableStream {
     _readableState:
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: BufferList { head: [Object], tail: [Object], length: 1 },
        length: 16384,
        pipes: [ServerResponse],
        pipesCount: 1,
        flowing: false,
        ended: false,
        endEmitted: false,
        reading: false,
        sync: false,
        needReadable: true,
        emittedReadable: true,
        readableListening: false,
        resumeScheduled: false,
        emitClose: true,
        destroyed: false,
        defaultEncoding: 'utf8',
        awaitDrain: 1,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: true,
     domain:
      Domain {
        domain: null,
        _events: [Object],
        _eventsCount: 2,
        _maxListeners: undefined,
        members: [Array] },
     _events: { end: [Array], data: [Function: ondata] },
     _eventsCount: 2,
     _maxListeners: undefined,
     retries: 0,
     abortHandler: [Function],
     aborter:
      Aborter {
        onabort: null,
        _aborted: false,
        children: [],
        abortEventListeners: [Array],
        parent: undefined,
        key: undefined,
        value: undefined,
        timer:
         Timeout {
           _called: true,
           _idleTimeout: -1,
           _idlePrev: null,
           _idleNext: null,
           _idleStart: 8593289,
           _onTimeout: null,
           _timerArgs: undefined,
           _repeat: null,
           _destroyed: true,
           domain: [Domain],
           _handle: [Timer],
           [Symbol(unrefed)]: false,
           [Symbol(asyncId)]: 1513663,
           [Symbol(triggerId)]: 1510098 } },
     getter: [Function],
     source:
      PassThrough {
        _readableState: [ReadableState],
        readable: true,
        domain: [Domain],
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: true,
        allowHalfOpen: true,
        _transformState: [Object] },
     start: 0,
     offset: 2784639,
     end: 4083440,
     maxRetryRequests: 5,
     progress: undefined,
     options: { maxRetryRequests: 5, progress: undefined } },
  domain:
   Domain {
     domain: null,
     _events:
      { removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture] },
     _eventsCount: 2,
     _maxListeners: undefined,
     members: [ [IncomingMessage], [ServerResponse] ] },
  domainThrown: false }

To Reproduce
Steps to reproduce the behavior:

  1. Require blob storage related types

Expected behavior
2. Types should be imported without errors

Screenshots

Additional context
Hosted in Azure Web App

@loarabia loarabia added 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. Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files) labels Sep 27, 2019
@ghost
Copy link

ghost commented Sep 27, 2019

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage

1 similar comment
@ghost
Copy link

ghost commented Sep 27, 2019

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage

@XiaoningLiu XiaoningLiu self-assigned this Sep 30, 2019
@XiaoningLiu XiaoningLiu added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Sep 30, 2019
@XiaoningLiu
Copy link
Member

"The request was aborted" error is thrown in Storage API calls when Aborter aborts a request. Type import will not trigger this.

Does simpliy import will trigger this? Or you can share a full reproduceable sample.

@nikodemrafalski
Copy link
Author

nikodemrafalski commented Oct 2, 2019

I'm not sure how Aborter could crash my process?

async deleteFileFromBlob(url) {
    const cfg = config.get('storage');
    const credentials = new Azure.SharedKeyCredential(cfg.storageAccount, cfg.storageAccessKey);
    const pipeline = Azure.StorageURL.newPipeline(credentials);
    const blob = new Azure.BlockBlobURL(url, pipeline);
    try {
      await blob.delete(Azure.Aborter.timeout(60 * 1000));
    } catch (e) {
      if (e.statusCode === 404) {
        this.context.logger.info(`Could not delete blob: ${blob.url}. Blob doesn't exist`);
      } else {
        throw e;
      }
    }
  }

This is the code I run, exceptions are eventually catched by external componen, logged and swallowed.
I verified that on my local dev env.
I tested that with very short timeout value, when an exception is thrown it contains also details on blob I tried to delete. Exception from my first post seems bit different, so I'm not sure what triggers it, that's why I thought that just requiring it causes that.
On azure somewhow, those exceptions surface unhandled and crash process.
I can observe them here

process.prependListener('uncaughtException', (err) => {

Also please notice that the call stack doesn't originate from timer.tick as it should in case of real timeout

@kartikshah9
Copy link

@XiaoningLiu can you provide inputs on the next steps for this

@XiaoningLiu
Copy link
Member

Hi @nikodemrafalski Please try with latest @azure/storage-blob latest version 12.0.1.

This issue maybe related to ms-rest-js package which throws abort error after HTTP request completes. If 12.0.1 still has this, we need help from @ramya-rao-a to take a look in ms-rest-js or @azure/core-http implementation.

@ramya-rao-a
Copy link
Contributor

cc @jeremymeng

@RupamShaw
Copy link

RupamShaw commented Apr 19, 2020

I am still having same issues. it goes on restart of server but oftenly I am facing this isuue

installed version  "@azure/storage-blob": "10.5.0" 
 "ms-rest-azure": "^3.0.0",

s RestError: The request was aborted
    at new RestError (/Users/shojo/ss/imgsrv/node_modules/@azure/ms-rest-js/dist/msRest.node.js:2400:28)

@jeremymeng
Copy link
Member

@RupamShaw are you using any Aborter? if possible could you please share your code snippets showing how you are calling storage-blob functions?

@RupamShaw
Copy link

@RupamShaw are you using any Aborter? if possible could you please share your code snippets showing how you are calling storage-blob functions?

Thanks for the reply.
here is my code snippet

const {
  Aborter,
  BlockBlobURL,
  uploadFileToBlockBlob,
  ContainerURL,
  ServiceURL,
  SharedKeyCredential,
  StorageURL,
} = require("@azure/storage-blob");

const ONE_MINUTE = 60 * 1000;
const credentials = new SharedKeyCredential(
  STORAGE_ACCOUNT_NAME,
  ACCOUNT_ACCESS_KEY
);
const pipeline = StorageURL.newPipeline(credentials);
const serviceURL = new ServiceURL(
  `https://${STORAGE_ACCOUNT_NAME}.blob.core.windows.net`,
  pipeline
);
const containerName = "pics";
const aborter = Aborter.timeout(30 * ONE_MINUTE);

async function executes(blobName) {
  try {
    const containerURL = ContainerURL.fromServiceURL(
      serviceURL,
     containerName
    );

    const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName);
    await blockBlobURL.delete(aborter);
    console.log(`Block blob "${blobName}" is deleted`);
  } catch (err) {
    console.log("Deleting blob issues", err);
    if (err.body && err.body.Code) {
      console.log("Deleting blob issues error code", err.body.Code);
      throw new Error(`Deleting blob issues ${err.body.Code}`);
    } 
    if (err.code) {
      console.log("Deleting blob issues error code", err.code);
      throw new Error(`Deleting blob issues ${err.code}`);
    }
    throw new Error(`Deleting blob issues.`);
  }
}

@RupamShaw
Copy link

is there any update why it throws?

@jeremymeng
Copy link
Member

@RupamShaw From your logs could you tell whether the The request was aborted issue happened before or after 30 minutes since the request was made?

@RupamShaw
Copy link

RupamShaw commented Apr 22, 2020

after 30 minutes of server started.
and making request its directly abort.

@jeremymeng
Copy link
Member

Isn't that expected since you set the aborter to time out after 30 minutes? Or were you sharing the same aborter instance for all requests? In your case you probably want to create a new aborter instance for each request.

@RupamShaw
Copy link

RupamShaw commented Apr 23, 2020

am I supposed to put

 const aborter = Aborter.timeout(30 * ONE_MINUTE);

inside this function executes(blobName) ?
Thanks
it solved issue. All good now.

@jeremymeng
Copy link
Member

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
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. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

7 participants