@azure/core-lro

中文文档
3.4.2发布于 2026/11/08MITTypeScriptESM + CJS近 30 天下载 7432.7万

Isomorphic client library for supporting long-running operations in node.js and browser.

原始使用文档
文档目录14 节
  1. Getting started
  2. Currently supported environments
  3. Installation
  4. Key concepts
  5. PollerLike
  6. OperationState
  7. createHttpPoller
  8. Examples
  9. Troubleshooting
  10. Logging
  11. Next steps
  12. Contributing
  13. Testing
  14. Code of Conduct

Azure Core LRO client library for JavaScript

This is the default implementation of long running operations in Azure SDK JavaScript client libraries which work in both the browser and NodeJS. This library is primarily intended to be used in code generated by the TypeSpec @azure-tools/typespec-ts emitter.

@azure/core-lro follows The Azure SDK Design Guidelines for Long Running Operations

Key links:

Getting started

Currently supported environments

Installation

This package is primarily used in generated code and not meant to be consumed directly by end users.

Key concepts

PollerLike

A poller is an object that can poll the long running operation on the server for its state until it reaches a terminal state. It also extends Promise<TResult>, so you can await it directly to get the final result. It provides the following:

  • operationState: a property that returns the current state of the operation, typed as a type that extends OperationState. It is undefined if the poller has not been submitted yet.
  • result: a property that returns the result of the operation when it completes and undefined otherwise
  • isDone: a property that returns whether the operation is in a terminal state
  • onProgress: registers callback functions to be called every time a polling response is received
  • poll: sends a single polling request
  • pollUntilDone: returns a promise that will resolve with the result of the operation
  • serialize: returns a promise that resolves to a serialized representation of the poller's state
  • submitted: returns a promise that resolves when the poller has been submitted successfully

OperationState

A type for the operation state. It contains a status field with the following possible values: notStarted, running, succeeded, failed, and canceled. It can be accessed as follows:

switch (poller.operationState?.status) {
  case "succeeded": // return poller.result;
  case "failed": // throw poller.operationState?.error;
  case "canceled": // throw new Error("Operation was canceled");
  case "running": // ...
  case "notStarted": // ...
}

createHttpPoller

A function that returns an object of type PollerLike. This poller behaves as follows in the presence of errors:

  • calls to poll and pollUntilDone will throw an error in case the operation has failed or canceled unless the resolveOnUnsuccessful option was set to true.
  • poller.operationState?.status will be set to "failed" or "canceled" when either the operation fails or it returns an error response.

Examples

Examples can be found in the samples folder.

Troubleshooting

Logging

Logs can be added at the discretion of the library implementing the Long Running Operation poller. Packages inside of azure-sdk-for-js use @azure/logger.

Next steps

Please take a look at the samples directory for detailed examples on how to use this library.

Contributing

If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.

Testing

To run our tests, first install the dependencies (with pnpm install), then run the unit tests with: pnpm run test:node.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

版本与发布记录

@azure/core-lro 共发布 608 个版本,首次发布于 2019/10/23;过去 12 个月发布了 76 个版本。

版本发布日期距今
3.4.2latest2026/11/08今天
3.4.12026/09/042 个月前
3.4.02026/07/143 个月前
3.3.2-alpha.20260311.2dev2026/03/127 个月前
3.3.2-alpha.20260310.22026/03/117 个月前
3.3.2-alpha.20260309.32026/03/107 个月前

关于 @azure/core-lro 的常见问题

@azure/core-lro 是什么?

Isomorphic client library for supporting long-running operations in node.js and browser.

如何安装 @azure/core-lro?

在项目目录运行 npm install @azure/core-lro,或使用 pnpm add / yarn add / bun add。

@azure/core-lro 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@azure/core-lro 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@azure/core-lro 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@azure/core-lro 可以商用吗?

@azure/core-lro 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@azure/core-lro 的下载量有多少?

根据 npm 官方下载统计,@azure/core-lro 在 2026/10/08 – 2026/11/06 这 30 天内被下载 74,327,403 次,日均约 2,477,580 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@azure/core-lro 还在维护吗?

最新版本 3.4.2 发布于 2026/11/08(今天);至今共发布 608 个版本,其中过去 12 个月发布了 76 个;首次发布于 2019/10/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。