Requesting host permissions throws undefined error

I am attempting to request permission to access a hostname entered by a user in the addon options screen. This code worked in Firefox 55. Now, it throws an error “Error: An unexpected error occurred”.

I have tried a number of things, including copying example code from https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/permissions/request

Below is the function primarily copied from the URL above. Putting this in my options page results in the unexpected error message.

I have got to be missing something simple… can anyone tell me what that is?

Full code that doesn’t work is here (options.js line 36 was added as the workaround, and the commented text below that is what fails): https://bitbucket.org/jprc8/redmine-timer-for-browsers/src/444ab73a21cc72b39f137c7e801e39498fee064a/options.js?at=master&fileviewer=file-view-default

 function saveOptions() {
 const permissionsToRequest = {
  permissions: ["bookmarks", "history"],
  origins: ["https://developer.mozilla.org/"]
}



  function onResponse(response) {
if (response) {
  console.log("Permission was granted");
} else {
  console.log("Permission was refused");
}
return browser.permissions.getAll();  
  }

  browser.permissions.request(permissionsToRequest)
.then(onResponse)
.then((currentPermissions) => {
console.log(`Current permissions:`, currentPermissions);
  });
}

document.getElementById("saveoptions").addEventListener("click", saveOptions);

Have you tried requesting the permission from the background script? The unexpected part of the error message tells me it’s a bug that needs to be reported and fixed, but it’d be good to narrow down the cause.