Closed
Bug 992509
Opened 11 years ago
Closed 7 years ago
tab.id throws TypeError: can't convert undefined to object
Categories
(Add-on SDK Graveyard :: General, defect, P2)
Add-on SDK Graveyard
General
Tracking
(Not tracked)
RESOLVED
INCOMPLETE
People
(Reporter: jmjacobs, Unassigned)
References
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36
Steps to reproduce:
The following code occasionally throws a TypeError when the .id property of a tab is accessed.
require('sdk/windows').browserWindows
.on('activate', function (win) {
console.log(win.tabs.activeTab.id);
})
.on('deactivate', function (win) {
console.log(win.tabs.activeTab.id);
});
I’ve observed exceptions from both the 'activate' and 'deactivate' event handlers, but I haven’t been able to reproduce them consistently.
Actual results:
Here are two of the stack traces collected in the wild using Airbrake:
resource://gre/modules/commonjs/sdk/tabs/utils.js:181 in "getTabId"
resource://gre/modules/commonjs/sdk/tabs/tab-firefox.js:151 in "TabTrait<.id"
resource://kifi-at-42go-dot-com/kifi-beta/lib/api.js:501 in "onWindowActivate"
resource://kifi-at-42go-dot-com/kifi-beta/lib/api.js:28 in "wrapped"
resource://gre/modules/commonjs/sdk/deprecated/events.js:153 in "_emitOnObject"
resource://gre/modules/commonjs/sdk/deprecated/events.js:123 in "_emit"
resource://gre/modules/commonjs/sdk/windows/firefox.js:160 in "onWindowActivation"
resource://gre/modules/commonjs/sdk/deprecated/events.js:153 in "_emitOnObject"
resource://gre/modules/commonjs/sdk/deprecated/events.js:123 in "_emit"
resource://gre/modules/commonjs/sdk/windows/observer.js:35 in "handleEvent"
resource://gre/modules/commonjs/sdk/tabs/utils.js:181 in "getTabId"
resource://gre/modules/commonjs/sdk/tabs/tab-firefox.js:153 in "TabTrait<.id"
resource://kifi-at-42go-dot-com/kifi-beta/lib/api.js:502 in "onWindowDeactivate"
resource://kifi-at-42go-dot-com/kifi-beta/lib/api.js:28 in "wrapped"
resource://gre/modules/commonjs/sdk/deprecated/events.js:153 in "_emitOnObject"
resource://gre/modules/commonjs/sdk/deprecated/events.js:123 in "_emit"
resource://gre/modules/commonjs/sdk/windows/firefox.js:166 in "onWindowActivation"
resource://gre/modules/commonjs/sdk/deprecated/events.js:153 in "_emitOnObject"
resource://gre/modules/commonjs/sdk/deprecated/events.js:123 in "_emit"
resource://gre/modules/commonjs/sdk/windows/observer.js:35 in "handleEvent"
Exceptions have been observed on both PCs and Macs.
I suspect the exceptions occur because tab.linkedPanel is undefined in the last line of getTabId:
return String.split(tab.linkedPanel, 'panel').pop();
Expected results:
The .id property of tab should never throw an exception.
Comment 1•11 years ago
|
||
Your assumption looks correct, but interested in also what scenario would a tab's `linkedPanel` be undefined, and can't seem to find anything w/r/t that
Comment 2•11 years ago
|
||
Any idea why a tab would not have a `linkedPanel`? Can easily fix the error throwing but won't fix the underlying problem.
Flags: needinfo?(evold)
Comment 3•11 years ago
|
||
(In reply to Jordan Santell [:jsantell] [@jsantell] from comment #2)
> Any idea why a tab would not have a `linkedPanel`? Can easily fix the error
> throwing but won't fix the underlying problem.
hmm I'm not convinced that `linkedPanel` is undefined, because all I see here is a stack trace without an error message.
I agree with comment 0, that tab.id should always return an id without throwing.
We should try to figure out why it does throw.
Flags: needinfo?(evold)
Reporter | ||
Comment 4•11 years ago
|
||
> hmm I'm not convinced that `linkedPanel` is undefined, because all I see
> here is a stack trace without an error message.
Erik, the error message is in the bug title:
"TypeError: can't convert undefined to object"
This is exactly the error type and message I get when I evaluate the following in the Firefox console:
String.split(undefined, 'panel').pop()
I suspect it’s triggered occasionally by race conditions when a brand new window is activated and when a window that’s closing is deactivated. Just a hunch.
Priority: -- → P2
Reporter | ||
Comment 5•11 years ago
|
||
This seems to have just gotten much worse in Aurora (31.0a2) and Beta (30.0). SDK tab objects no longer even have a .id property at all. In handlers for tabs.open, .close, and .activate, tab.id is now always undefined and 'id' in tab evaluates to false.
Comment 6•11 years ago
|
||
that doesn't seem like the same bug. the code would either work or throw, not return undefined.
Reporter | ||
Comment 7•11 years ago
|
||
Agreed. What they have in common is that tab.id is broken. I’ll file a new bug for the undefined case when I can create a minimal addon that reproduces the issue.
What I know for sure right now is that everything’s fine if I run my extension from source using cfx, but tab.id is undefined in many (perhaps all) event handlers if I run it as a packaged, installed addon.
Reporter | ||
Comment 8•11 years ago
|
||
Turns out the undefined tab.id issue was caused by one of our developers building and publishing to our users an .xpi using an old addon SDK (1.13). Everything seemed to work fine except that tab.id was always undefined. We’re going to add a safeguard in our shared build script to prevent this from happening again.
Here’s a screengrab showing the issue as I (and our users) observed it:
https://www.youtube.com/watch?v=B1hZk0XwnKA
Sorry for co-opting this issue. I’ll delete these irrelevant comments.
Comment 9•7 years ago
|
||
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in
before you can comment on or make changes to this bug.
Description
•