From the documentation for chrome.runtime.onMessage.addListener
:
This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until sendResponse is called).
So you just need to add return true;
after the call to getUrls
to indicate that you’ll call the response function asynchronously.