debugger.sendCommand broken on Windows but not on Mac?

9 views
Skip to first unread message

Adnan Khan

unread,
4:18 PM (2 hours ago) 4:18 PM
to Chromium Extensions
Hello all, I'm facing pretty much strange issue. Few months back I pushed update to my extension that would use below code to generate PDF out of HTML. It used to work fine for all operating system but from last 1 week, customers are complaining that its not working.

I use Windows machine, for me the below is broken and it throws error
```Error: Cannot access a chrome-extension:// URL of different extension```

interestingly, same flow works on Mac(80 percent of time). 

Now, it simply just sends back Base64 but it can not even attach debugger on Windows.

Site, I'm trying to do is credentials protected but it looks like this
```https://dealer.cudl.com/CUDL#/DealQueue/Applications```
Can it be because of the URL has `#`? If yes then why it works for Mac and not on Windows.

If I try to execute the code immediately like maybe in 1 second, it works and then breaks midway of saying ```debugged detached```. 


Code:
```

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  if (message.action === "capturePDF") {
    console.log("Message recieved for Capture PDF: ", message)
    const tabId = sender.tab.id;
    console.log("Tab ID: ", tabId, "Sender- :", sender)
    chrome.debugger.attach({ tabId: tabId }, "1.2", function () {
      chrome.debugger.sendCommand(
        { tabId: tabId },
        "Page.printToPDF",
        {},
        function (pdfResult) {
          console.log("PDF Result: ", pdfResult)
          chrome.debugger.detach({ tabId: tabId });

          if (chrome.runtime.lastError) {
            sendResponse({ error: chrome.runtime.lastError });
          } else {
            sendResponse({ data: pdfResult.data });
          }
        }
      );
    });

    return true; // Keeps the message channel open for the async response
  }
});
```
Reply all
Reply to author
Forward
0 new messages