Skip to content

Commit 7c11332

Browse files
committed
adapter-js: refactor for publishing
1 parent 9470aaa commit 7c11332

File tree

8 files changed

+54
-312
lines changed

8 files changed

+54
-312
lines changed

replayer-adapter-nodejs/README.md

Lines changed: 45 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Temporal Node.js Replayer Adapter
22

3-
This package provides a replayer adapter and interceptors for Temporal workflows in Node.js. It enables debugging and replaying workflows with breakpoint support in both standalone and IDE-integrated modes.
3+
Replayer adapter and interceptors for Temporal workflows in Node.js with breakpoint support for debugging.
44

55
## Features
66

7-
- **Standalone Mode**: Replay workflows from JSON history files with custom breakpoints
8-
- **IDE Integration Mode**: Connect to IDEs for interactive debugging
9-
- **Workflow Interceptors**: Automatically intercept workflow operations for debugging
10-
- **Activity Interceptors**: Intercept activity executions for comprehensive debugging
7+
- **Standalone Mode**: Replay workflows from JSON history files with breakpoints
8+
- **IDE Integration**: Connect to IDEs for interactive debugging
9+
- **Workflow Interceptors**: Automatically intercept workflow operations
1110
- **Breakpoint Support**: Set breakpoints at specific workflow event IDs
1211

1312
## Installation
@@ -21,18 +20,11 @@ npm install @temporal/replayer-adapter-nodejs
2120
### Standalone Mode
2221

2322
```typescript
24-
import {
25-
ReplayMode,
26-
setReplayMode,
27-
setBreakpoints,
28-
replay
29-
} from '@temporal/replayer-adapter-nodejs';
30-
31-
// IMPORTANT: Configure mode and breakpoints BEFORE calling replay()
32-
setReplayMode(ReplayMode.STANDALONE);
33-
setBreakpoints([1, 5, 10, 15]); // Set breakpoints at specific event IDs
23+
import { ReplayMode, replay } from '@temporal/replayer-adapter-nodejs';
3424

3525
const options = {
26+
mode: ReplayMode.STANDALONE,
27+
breakpoints: [1, 5, 10, 15],
3628
historyFilePath: './workflow-history.json',
3729
workerReplayOptions: {
3830
workflowsPath: require.resolve('./workflows'),
@@ -45,118 +37,83 @@ await replay(options, myWorkflow);
4537
### IDE Integration Mode
4638

4739
```typescript
48-
import {
49-
ReplayMode,
50-
setReplayMode,
51-
replay
52-
} from '@temporal/replayer-adapter-nodejs';
53-
54-
setReplayMode(ReplayMode.IDE);
40+
import { ReplayMode, replay } from '@temporal/replayer-adapter-nodejs';
5541

5642
const options = {
43+
mode: ReplayMode.IDE,
44+
debuggerAddr: 'http://127.0.0.1:54578',
5745
workerReplayOptions: {
5846
workflowsPath: require.resolve('./workflows'),
5947
}
6048
};
6149

62-
// Set environment variable for IDE connection
63-
process.env.WFDBG_HISTORY_PORT = '54578';
64-
6550
await replay(options, myWorkflow);
6651
```
6752

68-
## Breakpoint Management
53+
## Configuration Options
54+
55+
```typescript
56+
interface ReplayOptions {
57+
mode?: ReplayMode; // STANDALONE or IDE
58+
breakpoints?: number[]; // Event IDs to pause at
59+
historyFilePath?: string; // Required for STANDALONE mode
60+
debuggerAddr?: string; // Required for IDE mode
61+
workerReplayOptions?: ReplayWorkerOptions;
62+
}
63+
```
6964

70-
### Setting Breakpoints
65+
## Alternative Configuration
7166

72-
Breakpoints are set by event ID numbers that correspond to events in your workflow history:
67+
You can also configure using separate functions:
7368

7469
```typescript
75-
import { setBreakpoints } from '@temporal/replayer-adapter-nodejs';
70+
import { setReplayMode, setBreakpoints, setDebuggerAddr } from '@temporal/replayer-adapter-nodejs';
7671

77-
// Set breakpoints at events 1, 5, 10, and 15
72+
setReplayMode(ReplayMode.STANDALONE);
7873
setBreakpoints([1, 5, 10, 15]);
74+
setDebuggerAddr('http://127.0.0.1:54578');
7975

80-
// Update breakpoints (replaces previous ones)
81-
setBreakpoints([2, 4, 6, 8]);
82-
83-
// Clear all breakpoints
84-
setBreakpoints([]);
76+
await replay(options, myWorkflow);
8577
```
8678

87-
### Important Notes
88-
89-
1. **Order Matters**: Always call `setReplayMode()` and `setBreakpoints()` BEFORE calling `replay()`
90-
2. **Event IDs**: Breakpoint numbers should correspond to actual event IDs in your workflow history
91-
3. **Standalone vs IDE**: In standalone mode, you manage breakpoints manually. In IDE mode, the IDE manages them
92-
4. **Empty by Default**: Breakpoints start empty - you must explicitly set them
93-
9479
## API Reference
9580

9681
### Functions
9782

98-
#### `setReplayMode(mode: ReplayMode)`
99-
Set the replay mode (STANDALONE or IDE).
100-
101-
#### `setBreakpoints(eventIds: number[])`
102-
Set breakpoints at specific workflow event IDs. Replaces any existing breakpoints.
103-
104-
#### `replay(options: ReplayOptions, workflow: any): Promise<void>`
105-
Replay a workflow with the configured options and breakpoints.
83+
- `replay(options: ReplayOptions, workflow: any): Promise<void>`
84+
- `setReplayMode(mode: ReplayMode)`
85+
- `setBreakpoints(eventIds: number[])`
86+
- `setDebuggerAddr(addr: string)`
10687

10788
### Types
10889

109-
#### `ReplayMode`
110-
- `STANDALONE`: Replay using local history file
111-
- `IDE`: Replay with IDE integration
112-
113-
#### `ReplayOptions`
114-
```typescript
115-
interface ReplayOptions {
116-
workerReplayOptions?: ReplayWorkerOptions;
117-
historyFilePath?: string; // Required for STANDALONE mode
118-
}
119-
```
90+
- `ReplayMode.STANDALONE`: Replay using local history file
91+
- `ReplayMode.IDE`: Replay with IDE integration
12092

12193
## Troubleshooting
12294

12395
### Breakpoints Not Working
12496

125-
If breakpoints aren't triggering, check:
126-
127-
1. **Configuration Order**: Ensure you call `setBreakpoints()` before `replay()`
128-
2. **Event IDs**: Verify the event IDs exist in your workflow history
129-
3. **Mode Setting**: Confirm you've set the correct replay mode
130-
4. **Console Output**: Look for breakpoint checking messages in the console
131-
132-
### Example Console Output
97+
1. **Configuration**: Ensure breakpoints are set via options or functions
98+
2. **Event IDs**: Verify event IDs exist in workflow history
99+
3. **Mode**: Confirm correct replay mode is set
100+
4. **Console**: Check for breakpoint messages in console
133101

134-
When working correctly, you should see output like:
135-
```
136-
Breakpoints updated to: [1, 5, 10, 15]
137-
Standalone checking breakpoints: [1, 5, 10, 15], eventId: 1
138-
✓ Hit breakpoint at eventId: 1
139-
```
140-
141-
## Testing the Fix
142-
143-
A test script is included to verify breakpoints work correctly:
144-
145-
```bash
146-
npm run build
147-
node test-breakpoints.js
148-
```
102+
### IDE Connectivity
149103

150-
All tests should show "✓ PASS" if the breakpoint system is working correctly.
104+
For IDE mode, ensure:
105+
- Correct `debuggerAddr` is set
106+
- IDE debugger server is running
107+
- `WFDBG_HISTORY_PORT` environment variable is set if needed
151108

152109
## Examples
153110

154-
See the `example/` directory for complete working examples of both standalone and IDE integration modes.
111+
See `example/js/` directory for complete working examples.
155112

156113
## Contributing
157114

158-
Contributions are welcome! Please see the main repository for contribution guidelines.
115+
Contributions welcome! See main repository for guidelines.
159116

160117
## License
161118

162-
See the main repository for license information.
119+
See main repository for license information.

replayer-adapter-nodejs/example-worker-thread-usage.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

replayer-adapter-nodejs/example/basic-usage.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

replayer-adapter-nodejs/example/package-lock.json

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)