Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
Chrome extension stops working on website after perioid of time. (Stopping the connection)

Im new in developing and im developing extension for google chrome, but i have stumbled on issue i cant seem to wrap my head around..

extension works otherwise just as intended but for some websites it stops working after perioid of time.

Error:" Error: The client has been inactive since Mon Jan 10 2022 14:45:38 GMT+0200 (Eastern European Standard Time) and it has exceeded the inactivity timeout of 50000 ms. Stopping the connection. "

Manifestv3.json

{
  "manifest_version": 3,
  "name": "Add html",
  "version": "0.0.01",
  "permissions": [
    "contextMenus", 
    "activeTab", 
    "tabs",
    "clipboardRead",
    "clipboardWrite"
  ],
  "icons":{
    "128": "icon128.png",
    "48": "icon48.png",
    "16": "icon16.png"
  },
  
  "background": {
    "service_worker": "eventpage.js"
    
  },
  "content_scripts": [ {
      "matches": ["<all_urls>"],
      "all_frames": true,
      "match_about_blank": true,
      "js": ["content.js"]
  }],
  "description": "Adds html to highlighted text in textareas (example <b>XXX</b>)"
}

eventpage.js

chrome.runtime.onInstalled.addListener(function() {
    var parent = chrome.contextMenus.create({
        "title": 'parent',
        "contexts": ["selection"],
        "id": "myContextMenuId"
    });
});


chrome.contextMenus.onClicked.addListener((info, tab) => {
    console.log("clikki");
    console.log(info.selectionText);
  if (info.menuItemId.includes('Context')) {
    const text = ("<b>"+info.selectionText+"</b>");
    console.log(text);
    console.log(tab.id);
    chrome.tabs.sendMessage(tab.id, text);
  }
    });

content.js

console.log("Content script is running...");


chrome.runtime.onMessage.addListener(msg => {
    console.log("content.js toimii");
    console.log( msg );
    document.execCommand('insertText', false, msg);
  
});

console.log ("vituiksmen");

chrome.connection.hub.disconnected(function() {
   setTimeout(function() {
       console.log("restart");
       chrome.connection.hub.start();
   }, 5000); // Restart connection after 5 seconds.
});

chrome.connection.hub.disconnected doesent work. Eny suggestion to keep the site active alltho its not visible etc?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!