bf1efb2099
- Migration 007: repo_url on apps table + analysis table with FTS5 - Analysis struct, parser, CRUD, validation, hash computation - Selective purge: remote-only apps/analysis preserved across fn index - CLI: fn app list/clone/pull, fn analysis list/clone/pull - search/show/list now include analysis results - Apps removed from git tracking (content lives in Gitea repos) - .gitkeep for apps/ and analysis/ dirs - Bash functions: jupyter analysis pipeline, shell utilities - Browser domain: CDP functions moved from infra to browser Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39 lines
1.1 KiB
Markdown
39 lines
1.1 KiB
Markdown
---
|
|
name: cdp_close
|
|
kind: function
|
|
lang: go
|
|
domain: browser
|
|
version: "1.0.0"
|
|
purity: impure
|
|
signature: "func CdpClose(c *CDPConn, pid int) error"
|
|
description: "Cierra la conexion WebSocket CDP y opcionalmente mata el proceso Chrome por PID. Si c es nil, solo mata el proceso. Si pid <= 0, solo cierra la conexion. Siempre intenta ambas operaciones aunque una falle."
|
|
tags: [chrome, cdp, browser, automation, cleanup, devtools]
|
|
uses_functions: []
|
|
uses_types: []
|
|
returns: []
|
|
returns_optional: false
|
|
error_type: "error_go_core"
|
|
imports: [fmt, os]
|
|
tested: false
|
|
tests: []
|
|
test_file_path: ""
|
|
file_path: "functions/infra/cdp_close.go"
|
|
---
|
|
|
|
## Ejemplo
|
|
|
|
```go
|
|
pid, _ := ChromeLaunch(ChromeLaunchOpts{Port: 9222, Headless: true})
|
|
conn, _ := CdpConnect(9222)
|
|
|
|
defer CdpClose(conn, pid) // cierra WebSocket y mata Chrome
|
|
|
|
// O por separado:
|
|
defer CdpClose(conn, 0) // solo cierra WebSocket
|
|
defer CdpClose(nil, pid) // solo mata Chrome
|
|
```
|
|
|
|
## Notas
|
|
|
|
Usar en `defer` para garantizar cleanup. Si tanto la conexion como el proceso son invalidos, el error retornado corresponde al primero que fallo. Marca `c.closed = true` para evitar doble cierre.
|