port onDisconnect event is not fired when the tab is closed

Fixed Issue #9182205


Oct 4, 2016
This issue is public.
Found in
  • Microsoft Edge
Reported by 3 people

Sign in to watch or report this issue.

Steps to reproduce

  1. Create simple extension:
  "manifest_version": 2,
  "name": "onDisconnect bug example",
  "author": "sepikas.antanas@gmail.com",
  "version": "0.1",
  "content_scripts": [{
    "all_frames": true,
    "matches": ["http://*/*","https://*/*"],
    "js": ["content.js"],
    "run_at": "document_start"
  "background": {
    "persistent": true,
    "scripts": ["background.js"]
  "permissions": [
  1. Create connection from content.js to background.s
var port = browser.runtime.connect({
    name: "connectionName"
  1. Add connection listener in background.js
browser.runtime.onConnect.addListener(function (port) {
    console.log("connected port:", port);
    port.onDisconnect.addListener(function (port) {
        console.log("disconnected port:", port);
  1. Open extension background debug window.
  2. Open new tab with regular webpage e.g. facebook.com
  3. See message “connected port:” [object] in background debug console.
  4. Close facebook tab.
  5. There should be console message “disconnected port:” [object] but there isn’t.

PS. Also when connected port sender object doesn’t have frameId property.


Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Brad E.”

    Changed Assigned To from “Brad E.” to “Akshay P.”

    Changed Assigned To from “Akshay P.” to “Arif S.”

    Changed Status to “Confirmed”

    Changed Title from “port onDisconnect event” to “port onDisconnect event is not fired when the tab is closed”

    Changed Status from “Confirmed” to “In code review”

    Changed Status from “In code review” to “Fixed”

    Changed Assigned To to “Akshay P.”

    Changed Assigned To from “Akshay P.” to “Snehita P.”

  • Hello,

    Thank you for providing this information about the issue. We are pleased to report this feature is fixed in Edge 15063 and is available in our latest Insider Preview build.

    Best Wishes,

    The MS Edge Team

  • Microsoft Edge 40.15063.0.0 still can’t fired unload event when tab close.

    test code

    function OnUnLoad() {alert(“OnUnload”); }

You need to sign in to your Microsoft account to add a comment.

Sign in