aws / aws/aws-durable-execution-sdk-js
eslint-plugin: flag a child context whose body performs no durable operation
- Dominant language
- TypeScript
- Stars
- 84
- Forks
- 28
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 43
Description
A child context is a container for durable operations. A body that performs none — no `step`, `invoke`, `wait`, or nested context — gains nothing from the context: the work is not checkpointed, so it re-runs on every replay, and the context leaves no record of its own.
```ts
// flag: nothing durable inside the context
await context.runInChildContext("transform", async (ctx) => cheapTransform(input));
await context.map("transform", items, async (ctx, item) => cheapTransform(item), {
nesting: NestingType.FLAT,
});
// ok: the work is inside a step
await context.runInChildContext("transform", async (ctx) =>
ctx.step("compute", async () => cheapTransform(input)),
);
```
Beyond the wasted wrapper, the empty-context shape is the one case that replay of a summarized batch cannot reconstruct from the checkpoints alone, because a virtual item with no operations leaves nothing to probe. #894 handles it by recording per-item completion in the batch payload, but the shape remains against best practice and a lint rule is the right place to say so.
Suggested scope:
- report `runInChildContext` and `map`/`parallel` callbacks whose body contains no call to a durable operation on the injected context
- follow the callback through direct helper calls where the context is passed along, and skip reporting when the context parameter is unused or forwarded somewhere the rule cannot see
- message pointing at the `step` alternative
The TSDoc for `DurableContext.runInChildContext` and `MapFunc` now documents the rule, added in #894.
Contributor guide
Research direction
Start at the eslint-plugin rule entry point and inspect how existing callback-analysis rules and tests are organized. Trace runInChildContext, map, and parallel callbacks, including direct helper calls that receive the context. Done means callbacks with no durable operation report the step alternative, while unused or untraceable context parameters are skipped; add coverage for the shown cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100