2

I need to send information asynchronous from content script to popup page sendResponse works fine with synchronous but I don't know how to send asynchronous.

I'm working with Jsforce library works fine

chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
    if(request.action == "rest") {
        if(data.sid==undefined) {
            return null;
        }
        console.log(request);
        conn.apex.get(request.url, function(err, res) {
            if (err) {
                return console.error(err);
            }
            console.log(res); //**works fine but I need return to popup script**
            sendResponse({r: res}); //asynchronous does not work
        });
        return true;
    }
});
Xan
  • 74,770
  • 16
  • 179
  • 206
Hector Bayona
  • 97
  • 1
  • 2
  • 6
  • 1
    Were you able to get a solution to this? The solution to the linked question does not resolve the issue. You are already returning true from your listener to specify that its an asynchronous operation, but still you were facing the issue. I am facing the same issue. – shashi Oct 14 '15 at 07:24
  • @Xan the solution to that question does not answer this question, so I am not sure if this should be marked as duplicate. – shashi Oct 14 '15 at 07:25
  • @shashi Reopened, I agree that this may not be the same problem. – Xan Oct 14 '15 at 07:30
  • @shashi Could you provide a minimal example that shows the problem, and state the Chrome version that you're using? – Rob W Oct 14 '15 at 12:11
  • @RobW I am trying to repro this on a minimal example, but am not facing the issue there. But in the main extension that I am building the issue is still there. I had asked a question describing my specific issue here http://stackoverflow.com/questions/33103192/sendresponse-fails-when-using-a-promise . I continue my investigation into why I am facing this issue in the extension that I am building and will try to repro in a simpler code base. – shashi Oct 15 '15 at 01:02

0 Answers0