Skip to content

Commit bee0974

Browse files
authored
Added notes about docker setups and distinction from debuggers (#68)
1 parent 37ddf79 commit bee0974

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

.changeset/sour-trains-clap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"effect-vscode": patch
3+
---
4+
5+
Added notes about docker setups and distinction of DevTools from debuggers in terms of client/server model

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,39 @@ const program = Effect.log("Hello!").pipe(
2222
Effect.withSpan("Hi", { attributes: { foo: "bar" } }),
2323
Effect.forever,
2424
)
25-
const DevToolsLive = DevTools.layerWebSocket().pipe(
26-
Layer.provide(NodeSocket.layerWebSocketConstructor),
27-
)
25+
const DevToolsLive = DevTools.layer()
2826

2927
program.pipe(Effect.provide(DevToolsLive), NodeRuntime.runMain)
3028
```
3129

30+
The code above expects the DevTools server to be available at `localhost:34437`. If you are not running the DevTools client (e. g. backend) on the same machine, or if it's not available at localhost, you'll have to manully specify the websocket server url like so:
31+
```ts
32+
const DevToolsLive = DevTools.layer('ws://localhost:34437')
33+
```
34+
3235
If you are using `@effect/opentelemetry` in your project, then it is important that you provide the `DevTools` layer **before** your tracing layers, so the tracer is patched correctly.
3336

37+
Beware, that Effect DevTools extension does not behave like typical debugger UI, which connects to debugger port of target process. It's the other way around here. One of the reasons for that is to enable tracing of web applications, which are not able to expose ports, as servers do.
38+
39+
### Docker
40+
41+
In case you're using docker for local development and want to connect from your containerized application to DevTools server in VS Code, you'll have to do 2 things.
42+
43+
1. You'll have to make your host machine addressable from within the container, by adding extra host.
44+
45+
```yaml
46+
services:
47+
effect-backend:
48+
extra_hosts:
49+
- host.docker.internal:host-gateway
50+
```
51+
52+
2. You'll have to specify connection URL in your application to be
53+
54+
```ts
55+
DevTools.layer('ws://host.docker.internal:34437');
56+
```
57+
3458
## Usage
3559

3660
Once you have added the Layer to your project, open the Effect Dev Tools panel in vscode & click "Start the server" in the "Clients" panel.

0 commit comments

Comments
 (0)