New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is it possible to use chromedp for node js debugging? #913
Comments
No, First, Node.js uses URL like
Which does not contain the expected WebSocket URL. This logic was introduced by Try 1 with package main
import (
"context"
"log"
"github.com/chromedp/chromedp"
)
func main() {
actx, cancel := chromedp.NewRemoteAllocator(context.Background(),
"ws://127.0.0.1:9229/21e0413d-d55b-44dc-a96e-a3197f9d16c8",
)
defer cancel()
ctx, cancel := chromedp.NewContext(actx, chromedp.WithDebugf(log.Printf))
defer cancel()
if err := chromedp.Run(ctx); err != nil {
log.Fatal(err)
}
} Output:
Try 2 with package main
import (
"context"
"log"
"github.com/chromedp/chromedp"
)
func main() {
actx, cancel := chromedp.NewRemoteAllocator(context.Background(),
"ws://127.0.0.1:9229/21e0413d-d55b-44dc-a96e-a3197f9d16c8",
)
defer cancel()
ctx, cancel := chromedp.NewContext(actx, chromedp.WithDebugf(log.Printf))
defer cancel()
targets, err := chromedp.Targets(ctx)
if err != nil {
log.Fatal(err)
}
log.Printf("%+v", targets)
} Output:
|
Ahh, Thanks for the detailed answer. I guess, I just have to write my own client. It's awesome that you folks separated generated types from https://github.com/chromedp/cdproto chromedp. It'll be even more easy to write the client. |
Try 3 with It seems that we can work with the package main
import (
"context"
"log"
"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/cdproto/debugger"
"github.com/chromedp/chromedp"
)
func main() {
actx, cancel := chromedp.NewRemoteAllocator(context.Background(),
"ws://127.0.0.1:9229/21e0413d-d55b-44dc-a96e-a3197f9d16c8",
)
defer cancel()
ctx, cancel := chromedp.NewContext(actx, chromedp.WithDebugf(log.Printf))
defer cancel()
if err := run(ctx,
chromedp.ActionFunc(func(ctx context.Context) error {
_, err := debugger.Enable().Do(ctx)
return err
}),
debugger.SetBreakpointsActive(false),
); err != nil {
log.Fatal(err)
}
}
func run(ctx context.Context, actions ...chromedp.Action) error {
// to make sure chromedp.initContextBrowser is called
if err := chromedp.Run(ctx); err != nil && err.Error() != "'Target.createTarget' wasn't found (-32601)" {
return err
}
c := chromedp.FromContext(ctx)
// to run actions with the Browser executor
// chromedp.Run will run actions with the Target executor
return chromedp.Tasks(actions).Do(cdp.WithExecutor(ctx, c.Browser))
} |
I tried with it. But I got error
Btw, does chromedp handles event from the remote server eg event https://chromedevtools.github.io/devtools-protocol/tot/Debugger/#event-breakpointResolved |
For event handling, please see https://pkg.go.dev/github.com/chromedp/chromedp#ListenBrowser and https://pkg.go.dev/github.com/chromedp/chromedp#ListenTarget. For the |
Closing due to lack of activity. |
I want to hit nodejs debugger api using chromedp.
Is it possible to use chromedp since nodejs also exposing chrome dev tool protocol
https://nodejs.org/api/debugger.html#debugger_advanced_usage
The text was updated successfully, but these errors were encountered: