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

557
Views
Extension context invalidated - Chrome extension

I'm writing a screen capture chrome extension and it takes screenshots on the document "onClick" event.

Currently, I'm sending an event from my "popup script" and receiving it in the content script as you can see.

but after reloading the extension or updating it, I get the Extension context invalidated on each document click. reloading the tab will fix it but it's not the desired solution. this is my content script:

const sendMessage = (e) => {
  try {
    chrome.runtime.sendMessage({
      type: "screenshot"
    });
  } catch (e) {
    console.log("error", e);
  }
};

const handleClick = (e) => {
  e.stopImmediatePropagation();
  sendMessage(e);
};

const handleMessage = (request) => {
    document.addEventListener("click", handleClick, true);
};

chrome.runtime.onMessage.addListener(handleMessage);

I tried every solution that I find but didn't work perfectly. and I think this is a chrome bug, why they don't fix it?

about 4 years ago · Santiago Gelvez
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!