From 88334b4f12dab5d3b1068cbaf7619582ea864155 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 16 Nov 2023 21:06:26 +0100 Subject: Try not cancelling context Turns out this is what was closing the extension background page DevTools window. We shouldn't run the context cancel function. --- internal/swextreload.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'internal/swextreload.go') diff --git a/internal/swextreload.go b/internal/swextreload.go index e8af38a..b66be95 100644 --- a/internal/swextreload.go +++ b/internal/swextreload.go @@ -67,6 +67,7 @@ func Reload( err = reloadTab( allocatorContext, extensionIDs[0], + firstExtensionTarget, isExtensionManifestV2(firstExtensionTarget), ) if err != nil { @@ -111,7 +112,7 @@ func reloadExtension( } targetCtx, cancel := chromedp.NewContext(ctx, chromedp.WithTargetID(targetID)) - defer cancel() + // defer cancel() log.Printf("Connected to target") @@ -141,6 +142,7 @@ func reloadExtension( func reloadTab( ctx context.Context, extensionID string, + letarget *target.Info, isExtensionManifestV2 bool, ) error { ctx, cancel := chromedp.NewContext(ctx) @@ -183,6 +185,9 @@ func reloadTab( defer cancel() } + ctx, cancel = chromedp.NewContext(ctx, chromedp.WithTargetID(letarget.TargetID)) + // defer cancel() + var tabsResp []byte err := chromedp.Run( ctx, -- cgit v1.2.3