Skip to content

Commit d147c67

Browse files
committed
x
1 parent b31d903 commit d147c67

File tree

2 files changed

+127
-65
lines changed

2 files changed

+127
-65
lines changed

README.md

Lines changed: 126 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,13 @@ This debugger solves these challenges by leveraging the **workflow replayer** -
2020
###
2121
- **Multi-language Support**: Works with Go, TypeScript/Node.js, and Python via adapters
2222
- **VS Code Extension**: Open a panel, load history, set event breakpoints, and replay with your adapter
23-
- **Event-based Breakpoints**: Set breakpoints on specific workflow history events
24-
25-
## Who Is This For?
26-
27-
- **Temporal Workflow Developers**: Anyone building workflows with Temporal's SDK
28-
29-
Whether you're debugging a complex workflow that's failing in production or just want a better development experience while building new workflows, this debugger provides the tools you need to understand and fix your Temporal workflow code efficiently.
30-
23+
- **History Event-based Breakpoints**: Set breakpoints on specific workflow history events
3124

3225
## Installation
3326

3427
### Prerequisites
3528

36-
1. **Install tdlv debugger** from [GitHub Release](https://github.com/phuongdnguyen/temporal-workflow-debugger/releases/tag/tdlv-v0.0.1)
29+
1. **Install tdlv debugger** from [GitHub Release](https://github.com/phuongdnguyen/temporal-workflow-debugger/releases/tag/tdlv-v0.0.2)
3730

3831
Verify installation:
3932
```bash
@@ -59,7 +52,7 @@ Whether you're debugging a complex workflow that's failing in production or just
5952

6053
### IDE Plugins
6154

62-
**VS Code** (Go, Python, JavaScript):
55+
**VS Code** :
6356
<a href="https://marketplace.visualstudio.com/items?itemName=phuongdnguyen.temporal-workflow-debugger"><img src="https://img.shields.io/badge/Install%20from%20VS%20Code%20Marketplace-007ACC?logo=visual-studio-code&logoColor=white" alt="Install from VS Code Marketplace"></a>
6457

6558
### Replayers
@@ -94,60 +87,103 @@ To connect to different servers:
9487
- Edit `Address` field
9588
- For TLS (Temporal Cloud): check box and select client cert/key
9689

97-
#### Language Configuration
90+
### Debug setup
91+
Tested language version
92+
- Go 1.19+.
93+
- NodeJS v22.17.0, Npm 10.9.2
94+
- Python 3.12.11
95+
9896

99-
Set your debugging language in workspace settings:
97+
#### TypeScript
98+
99+
Create a small `replayer.ts` in your project that runs the Tyepscript replayer adapter in IDE mode and registers your workflow function, for example:
100+
101+
1. Install the replayer first:
100102

101-
```json
102-
{
103-
"temporal.debugLanguage": "go" // "typescript", "python", "java"
104-
}
103+
```
104+
npm i @phuongdnguyen/replayer-adapter-nodejs --save
105105
```
106106

107-
#### Entrypoint Configuration
107+
2. Install the debugger [tdlv](https://github.com/phuongdnguyen/temporal-workflow-debugger/releases/tag/tdlv-v0.0.2) and add it to PATH
108+
3. Verify tldv is installed in PATH
108109

109-
**TypeScript/JavaScript**
110-
```json
111-
{
112-
"temporal.replayerEntryPoint": "src/debug-replayer.ts"
113-
}
110+
```
111+
tdlv --help
112+
Missing required flags: -lang
113+
114+
Tdlv (Temporal delve) is a temporal workflow debugger
115+
116+
Usage: tdlv [options]
117+
118+
-help
119+
Tdlv (Temporal delve) is a temporal workflow debugger, provide ability to focus on user workflow code in debug sessions (alias: -h)
120+
-install
121+
auto-install missing language debuggers
122+
-lang string
123+
[required] language to use for the workflow, available options: [go, python, js]
124+
-p int
125+
port for remote debugging (default 60000)
126+
-start
127+
start debugger
114128
```
115129

116-
**Go**
117-
```json
118-
{
119-
"temporal.debugLanguage": "go",
120-
"temporal.replayerEntrypoint": "main.go"
130+
4. Your entrypoint file should import the replayer adapter and your workflow:
131+
132+
```typescript
133+
import { exampleWorkflow } from "./workflow"
134+
import { ReplayMode, replay } from "@phuongdnguyen/replayer-adapter-nodejs"
135+
136+
async function main() {
137+
const opts = {
138+
mode: ReplayMode.IDE,
139+
workerReplayOptions: {
140+
workflowsPath: require.resolve("./workflow.ts"),
141+
},
142+
}
143+
144+
await replay(opts, exampleWorkflow)
145+
}
146+
147+
if (require.main === module) {
148+
main().catch((error) => {
149+
console.error("Error:", error)
150+
process.exit(1)
151+
})
121152
}
122153
```
123154

124-
**Python**
155+
5. Open or create `.vscode/settings.json` and add the config field:
156+
125157
```json
126158
{
127-
"temporal.debugLanguage": "python",
128-
"temporal.replayerEntrypoint": "replayer.py"
159+
"temporal.replayerEntryPoint": "replayer.ts"
129160
}
130161
```
131162

132-
### Replayer setup
133-
Tested language version
134-
- Go 1.19+.
135-
- NodeJS v22.17.0, Npm 10.9.2
136-
- Python 3.12.11
163+
_Note that the file must be within your project directory so it can find `node_modules/`._
164+
165+
#### Go
166+
167+
1. Get the replayer code
168+
169+
```
170+
go get -u github.com/phuongdnguyen/temporal-workflow-debugger/replayer-adapter-go@latest
171+
```
172+
173+
2. Create a small `main.go` in your project that runs the Go replayer adapter in IDE mode and registers your workflow function, for example:
137174

138-
#### Go Example
139175
```go
140176
package main
141177

142178
import (
143179
"go.temporal.io/sdk/worker"
144-
replayeradapter "github.com/phuongdnguyen/temporal-workflow-debugger/replayer-adapter-go"
180+
replayer_adapter_go "github.com/phuongdnguyen/temporal-workflow-debugger/replayer-adapter-go"
145181
"example/pkg/workflows"
146182
)
147183

148184
func main() {
149-
replayeradapter.SetReplayMode(replayeradapter.ReplayModeIde)
150-
err := replayeradapter.Replay(replayeradapter.ReplayOptions{
185+
replayer_adapter_go.SetReplayMode(replayer_adapter_go.ReplayModeIde)
186+
err := replayer_adapter_go.Replay(replayer_adapter_go.ReplayOptions{
151187
WorkerReplayOptions: worker.WorkflowReplayerOptions{DisableDeadlockDetection: true},
152188
}, workflows.ExampleWorkflow)
153189
if err != nil {
@@ -156,33 +192,31 @@ func main() {
156192
}
157193
```
158194

159-
#### TypeScript/Node.js Example
160-
```typescript
161-
import { exampleWorkflow } from './workflow';
162-
import { ReplayMode, replay } from '@phuongdnguyen/replayer-adapter-nodejs';
195+
3. Configure the extension:
163196

164-
async function main() {
165-
const opts = {
166-
mode: ReplayMode.IDE,
167-
workerReplayOptions: {
168-
workflowsPath: require.resolve('./workflow.ts'),
169-
debugMode: true,
170-
},
171-
debuggerAddr: 'http://127.0.0.1:54578'
172-
};
173-
174-
await replay(opts, exampleWorkflow);
197+
```json
198+
{
199+
"temporal.debugLanguage": "go",
200+
"temporal.replayerEntrypoint": "main.go"
175201
}
202+
```
176203

177-
if (require.main === module) {
178-
main().catch((error) => {
179-
console.error('Error:', error);
180-
process.exit(1);
181-
});
182-
}
204+
4. Run "Temporal: Open Panel"
205+
5. Enter a Workflow Id or choose a history JSON file
206+
6. Click `Load History`
207+
7. Select history events that you want the workflow to be stopped on
208+
8. Hit `Start debug session`
209+
210+
#### Python
211+
212+
1. Make sure your Python environment has the required dependencies installed:
213+
214+
```bash
215+
pip install temporalio replayer-adapter-python
183216
```
184217

185-
#### Python Example
218+
2. Create a small script (e.g. `replayer.py`) that uses the Python replayer adapter in IDE mode and references your workflow:
219+
186220
```python
187221
import asyncio
188222
from replayer_adapter_python.replayer import (
@@ -191,15 +225,42 @@ from replayer_adapter_python.replayer import (
191225
from workflow import UserOnboardingWorkflow
192226

193227
async def main():
194-
set_replay_mode(ReplayMode.IDE)
195-
opts = ReplayOptions(worker_replay_options={})
196-
result = await replay(opts, UserOnboardingWorkflow)
197-
print(f"Result: {result}")
228+
"""Run ide examples"""
229+
try:
230+
# Set up ide mode
231+
set_replay_mode(ReplayMode.IDE)
232+
233+
# Create replay options
234+
opts = ReplayOptions(
235+
worker_replay_options={},
236+
)
237+
result = await replay(opts, UserOnboardingWorkflow)
238+
print(f"Result: {result}")
239+
except Exception as e:
240+
print(f"Replay failed: {e}")
198241

199242
if __name__ == "__main__":
200243
asyncio.run(main())
201244
```
202245

246+
3. Configure the extension:
247+
248+
```json
249+
{
250+
"temporal.debugLanguage": "python",
251+
"temporal.replayerEntryPoint": "replayer.py"
252+
// If you want use a custom python rather the one in PATH
253+
// "temporal.python": "/Your/path/to/python"
254+
}
255+
```
256+
257+
4. Run "Temporal: Open Panel"
258+
5. Enter a Workflow Id or choose a history JSON file
259+
6. Click `Load History`
260+
7. Select history events that you want the workflow to be stopped on
261+
8. Hit `Start debug session`
262+
263+
203264
## Architecture
204265

205266
### Overview

vscode-debugger-extension/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,4 @@ if __name__ == "__main__":
208208
6. Click `Load History`
209209
7. Select history events that you want the workflow to be stopped on
210210
8. Hit `Start debug session`
211+

0 commit comments

Comments
 (0)