目录
Silan He

fix(ci):Update checkout ref to use release tag name (#588)

Issue #, if available:

Description of changes:

If target_commitish is not specified in the create_release API call, then it defaults to the branch used to create the release. The Github release UI does not seem to provide the commit SHA for the tag as the target_commitish. See here where we only checkout the branch.

Checking out the commit referenced by the tag_name of the release instead. This preserves our ability to release in different branches but ensures that the release is the code commit referenced by the tag and not the newest commit in the branch.

Just tested in my personal dummy package repo: * https://github.com/SilanHe/test-publish-npm-silanhe/actions/runs/26654766314/job/78562008979#step:2:67 * https://www.npmjs.com/package/test-publish-npm-silanhe/v/1.4.2?activeTab=versions

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

5天前381次提交

AWS Durable Execution SDKs for JavaScript

Build NPM Version OpenSSF Scorecard License Node.js


Build resilient, long-running AWS Lambda functions with automatic state persistence, retry logic, and workflow orchestration. Lambda durable functions can run for up to one year while maintaining reliable progress through checkpoints and automatic failure recovery.

✨ Key Features

  • Durable Execution – Automatically persists state and resumes from checkpoints after failures
  • Automatic Retries – Configurable retry strategies with exponential backoff and jitter
  • Workflow Orchestration – Compose complex workflows with steps, child contexts, and parallel execution
  • External Integration – Wait for callbacks from external systems (human-in-the-loop, webhooks)
  • Batch Operations – Process arrays with concurrency control and completion policies
  • Cost Efficient – Pay only for active compute time; waits suspend without charges
  • Type Safety – Full TypeScript support with comprehensive type definitions

📦 Packages

This monorepo contains the following NPM packages:

Package Description NPM
@aws/durable-execution-sdk-js Core SDK for building durable Lambda functions npm
@aws/durable-execution-sdk-js-testing Testing utilities for local development and CI/CD npm
@aws/durable-execution-sdk-js-eslint-plugin ESLint rules for durable function best practices npm

🚀 Quick Start

Installation

npm install @aws/durable-execution-sdk-js

Your First Durable Function

import {
  withDurableExecution,
  DurableContext,
} from "@aws/durable-execution-sdk-js";

const handler = async (event: any, context: DurableContext) => {
  // Use the context logger for structured logging
  context.logger.info("Starting workflow", { userId: event.userId });

  // Execute a durable step with automatic retry
  const userData = await context.step("fetch-user", async (stepCtx) => {
    // Step-scoped logger includes step metadata
    stepCtx.logger.debug("Fetching user from database");
    return fetchUserFromDB(event.userId);
  });

  // Wait for 5 seconds (no compute charges during wait)
  await context.wait({ seconds: 5 });

  // Process data in another step
  const result = await context.step("process-user", async (stepCtx) => {
    return processUser(userData);
  });

  context.logger.info("Workflow completed", { result });
  return result;
};

export const lambdaHandler = withDurableExecution(handler);

Invoking Your Durable Function

Durable functions require a qualified identifier for invocation. You must specify a version or alias. Unqualified ARNs or function names without a suffix are not supported to ensure deterministic replay behavior.

The following example uses asynchronous invocation (--invocation-type Event), which queues the event and returns immediately, enabling executions that can run for up to one year:

aws lambda invoke \
  --function-name my-durable-function:$LATEST \
  --invocation-type Event \
  --cli-binary-format raw-in-base64-out \
  --payload '{"userId": "12345"}' \
  response.json

[!TIP] To ensure idempotent execution, use the --durable-execution-name parameter. See Idempotency in the Lambda developer guide for additional information.

[!IMPORTANT] For production deployments, use numbered versions or aliases instead of $LATEST for deterministic replay behavior. See Invoking durable Lambda functions for more details.

📚 Documentation

  • AWS Documentation – Official AWS Lambda durable functions guide
  • SDK README – Detailed SDK usage guide with code examples
  • API Reference – Complete technical reference with type definitions
  • Concepts & Use Cases – Replay model, best practices, and real-world patterns
  • Examples – Working examples including hello-world, callbacks, parallel processing, and more

🧪 Testing

The testing SDK enables local development and unit testing without deploying to AWS, as well as cloud testing against deployed Lambda functions:

npm install @aws/durable-execution-sdk-js-testing --save-dev
import { LocalDurableTestRunner } from "@aws/durable-execution-sdk-js-testing";

// Create runner with skipTime to fast-forward through waits
await LocalDurableTestRunner.setupTestEnvironment({ skipTime: true });

const runner = new LocalDurableTestRunner({
  handlerFunction: myDurableHandler,
});

const result = await runner.run({ userId: "123" });

// Assert execution status
expect(result.getStatus()).toBe("SUCCEEDED");
expect(result.getResult()).toEqual({ processedUser: "..." });

// Assert number of Lambda invocations (initial+replay after wait)
expect(result.getInvocations().length).toBe(2);

// Assert operations executed
const operations = result.getOperations();
expect(operations.length).toBe(3); // 2 steps + 1 wait

// Inspect individual operations
const fetchStep = runner.getOperation("fetch-user");
expect(fetchStep.getStatus()).toBe("SUCCEEDED");

See the Testing SDK documentation for more details.

💬 Feedback & Support

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

🔒 Security

See CONTRIBUTING for information about reporting security issues.

📄 License

This project is licensed under the Apache-2.0 License. See LICENSE for details.

邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号