Feature - Support "use step" in Class Instance Methods
Open
@TooTallNate is already working on this.
Since Jan 9, 2026.
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 365
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 169
Description
Problem
Currently, the workflow system only supports "use step" in:
- Static methods
- Standalone functions
- Object methods
However, class instance methods cannot be marked with "use step", which limits the ability to create well-structured, stateful workflow components using object-oriented patterns.
This results in the following error:
Instance methods cannot be marked with "use step". Only static methods, functions, and object methods are supported.
Use Case
In complex workflow orchestration scenarios, managing state across multiple workflow steps would benefit greatly from class-based patterns. Here's a real-world example:
Current Workaround (Verbose & Error-Prone)
// Need to pass stream to every function call
async function emitEventStep(stream: WritableStream, event: Event) {
"use step";
const writer = stream.getWriter();
try {
await writer.write(event);
} finally {
writer.releaseLock();
}
}
// Called dozens of times throughout the workflow
await emitEventStep(workflowStream, event1);
await emitEventStep(workflowStream, event2);
await emitEventStep(workflowStream, event3);
// ... repeated 20+ times
Desired Approach
class WorkflowStreamManager {
private writer: WritableStreamDefaultWriter | null = null;
private stream: WritableStream;
private closed = false;
constructor(stream: WritableStream) {
this.stream = stream;
}
async write(event: Event) {
"use step"; // Not supported
if (this.closed) {
console.warn("Stream already closed");
return;
}
if (!this.writer) {
this.writer = this.stream.getWriter();
}
await this.writer.write(event);
}
async close() {
"use step"; // Not supported
if (this.closed) return;
this.closed = true;
if (this.writer) {
await this.writer.close();
this.writer = null;
}
}
}
// Usage is much cleaner
const streamManager = new WorkflowStreamManager(workflowStream);
await streamManager.write(event1);
await streamManager.write(event2);
await streamManager.write(event3);
await streamManager.close();
Resource Management
class WorkflowResourceManager {
async acquire(resource: string) { "use step"; /* ... */ }
async release(resource: string) { "use step"; /* ... */ }
async cleanup() { "use step"; /* ... */ }
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.