bugzilla.mozilla.org has resumed normal operation. Attachments prior to 2014 will be unavailable for a few days. This is tracked in Bug 1475801.
Please report any other irregularities here.

Strange Error message in error console: [Exception... "Component is not available'Component is not available' when calling method: [nsIActivityManager::removeActivity]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" ...

NEW
Unassigned

Status

Thunderbird
General
3 years ago
2 years ago

People

(Reporter: ISHIKAWA, Chiaki, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
This is with the  RELEASEed (ESR) version on Windows 7 64-bit.


The mail server of one ISPs which I use has a habit of timing out after downloading 150-500 e-mails (the numbers are random), and I think it is a grave error on the side of TB to fail to report that there is a timeout and thus download is aborted
for remaining e-mails.
The failure to report such an issue is a bug worth filing on its own.

But to check whether such a behavior is recorded in error console, I looked into the error console and found a very strange error message: it looks malformed one way or the other.

Sorry it has Japanese characters since I use Japanese locale.

--- quote the original error ---
エラー: [Exception... "Component is not available'Component is not
available' when calling method: [nsIActivityManager::removeActivity]"
nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame ::
resource:///modules/activity/pop3Download.js ::
pop3DownloadModule.onDownloadCompleted :: line 124"  data: no]
ソースファイル: resource:///modules/activity/pop3Download.js
行: 124
----------------

Note the duplicated string in tandem:
"Component is not available'Component is not available'

So there are two issues.
a "Component" for something is "UNAVAILABLE", and the error is thrown.
This is the first error.

The error string seems to be messed up. This is the second error.

As for the first error, the error occurs on line 124 of the following function:
http://mxr.mozilla.org/comm-central/source/mail/components/activity/modules/pop3Download.js#124

onDownloadCompleted : function(aFolder, aNumMsgsDownloaded) {
91     this.log.info("in onDownloadCompleted");
92 
93     this.activityMgr.removeActivity(this._mostRecentActivityForFolder[aFolder.URI].eventID);
94 
95     let displayText;
96     if (aNumMsgsDownloaded > 0)
97     {
98       displayText = PluralForm.get(aNumMsgsDownloaded, this.getString("pop3EventStatusText"));
99       displayText = displayText.replace("#1", aNumMsgsDownloaded);
100     }
101     else
102       displayText = this.getString("pop3EventStatusTextNoMsgs");
103 
104     let statusText = aFolder.server.prettyName;
105 
106     // create an activity event
107     let event = new nsActEvent(displayText,
108                                aFolder,
109                                statusText,
110                                Date.now(),  // start time
111                                Date.now()); // completion time
112 
113     event.iconClass = "syncMail";
114 
115     let downloadItem = {numMsgsDownloaded: aNumMsgsDownloaded};
116     this._mostRecentActivityForFolder[aFolder.URI] = downloadItem;
117     downloadItem.eventID = this.activityMgr.addActivity(event);
118     if (!aNumMsgsDownloaded) {
119       // if we didn't download any messages this time, and the prev event
120       // for this folder also didn't download any messages, remove the
121       // prev event from the activity manager.
122       let prevItem = this._prevActivityForFolder[aFolder.URI];
123       if (prevItem != undefined && !prevItem.numMsgsDownloaded) {
124         if (this.activityMgr.containsActivity(prevItem.eventID))
125           this.activityMgr.removeActivity(prevItem.eventID);
126       }
127     }
128   },

The check on line 118 and the subsequent comment suggests that
the timeout for accessing the mail server may trigger the
processing in this code path.

Maybe the check for "undefined"-ness on line 124 ("!= undefined") does not work as intended, and we are calling non-existing method or used null(?) or something.
[I have found that sometimes the check for undefinedness in JavaScript
does not seem to work as expected. I wish JavaScript has a reliable built-in for this purpose ala Lisp's boundp that works all the time.]

As for the strange error message, I have no idea where to look.

I searched for "Component is not available" in C-C tree using MXR and
it found 2 matching lines in 2 files
/mozilla/dom/base/domerr.msg (View Hg log or Hg annotations)
    line 135 -- DOM_MSG_DEF(NS_ERROR_NOT_AVAILABLE , "Component is not available")

/mozilla/js/xpconnect/src/xpc.msg (View Hg log or Hg annotations)
    line 85 -- XPC_MSG_DEF(NS_ERROR_NOT_AVAILABLE , "Component is not available")
 
So maybe there is a double fault of a sort?
One from XPC failure AND DOM-error and these two messages are concatenated together???
Experts opinion welcome.

As for the failure to report timeout from the server  in a user-visible manner at all, I am filing a separate bug.
 
TIA
(Reporter)

Updated

3 years ago
Summary: Strange Error message in e rror console: [Exception... "Component is not available'Component is not available' when calling method: [nsIActivityManager::removeActivity]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" ... → Strange Error message in error console: [Exception... "Component is not available'Component is not available' when calling method: [nsIActivityManager::removeActivity]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" ...

Comment 1

3 years ago
(In reply to ISHIKAWA, Chiaki from comment #0)
> [I have found that sometimes the check for undefinedness in JavaScript
> does not seem to work as expected. I wish JavaScript has a reliable built-in
> for this purpose ala Lisp's boundp that works all the time.]

You can use === and !== if you need
Otherwise, you just get truthy and falsy comparisons.
(Reporter)

Comment 2

3 years ago
I tested variations including
typeof previtem !== "undefined"
and the symptom did not change, and so I suspect
it is not related to the if check but
the problem is calling removeActivity method.

(But, I was not sure how to change omni.ja in released build,
and followed
the steps in the following URL.
https://developer.mozilla.org/en-US/docs/Mozilla/About_omni.ja_%28formerly_omni.jar%29

After changing the .js file, I recreated .ja (from .zip) file and replaced it.
When the error occurred, I could trace from the error console to the newly
modified content, and so I think my change is valid and is used by TB now. I did not know we can tweak the
released TB's .js files this way.)
 
So the issue seems to be remove Activity not callable under my environment sometimes.
(I suspect this code path is not treaded often. Only on a flakey connection or servers with hiccups we
enter this code path.)

TIA
(Reporter)

Comment 3

3 years ago
Aha, this may be the culprit.
http://mxr.mozilla.org/comm-central/source/mail/components/activity/nsActivityManager.js#94

94  removeActivity: function (aID) {
95     let activity = this._activities[aID];
96 
97     if (!activity)
98       throw Cr.NS_ERROR_NOT_AVAILABLE; <==== HERE!
99 
100     // make sure that the activity is not in-progress state
101     if (activity instanceof Ci.nsIActivityProcess &&
102         activity.state == Ci.nsIActivityProcess.STATE_INPROGRESS)
103       throw Cr.NS_ERROR_FAILURE;
104 
105     // remove the activity
106     delete this._activities[aID];
107 
108     // notify all the listeners
109     for each (let [, value] in Iterator(this._listeners)) {
110       try {
111         value.onRemovedActivity(aID);
112       }
113       catch(e) {
114         // ignore the exception
115       }
116     }
117   },

Maybe we should not call 
|removeActivity| when prevItem.eventID
is null (?)
Well, just before calling |removeACtivity|
we are checking
this.activityMgr.containsActivity(prevItem.eventID)
and 
145   containsActivity: function (aID) {
146     return !!this._activities[aID];
147   },

I am a little uncomforable with "!!" since I am not JS expert. But it looks what it intends to do.

So my final guess is this. In the code below,
probably line 123 ought to add the check for
prevItem.eventID being null or undefined.

122       let prevItem = this._prevActivityForFolder[aFolder.URI];
123       if (prevItem != undefined && !prevItem.numMsgsDownloaded) {
124         if (this.activityMgr.containsActivity(prevItem.eventID))
125           this.activityMgr.removeActivity(prevItem.eventID);

(But if prevItem.eventID is not defined, I wonder why |containsActivity| did not complain.
Isn't array[undefined] or array[null] supposed t generate an error?
Or is there a special constant that is adopted by mozilla code (TB for instance)
to signal an invalid eventID like zero? 
Unless another thread changes the state of this._activities[a certain value] between line 124 and 125
I find it tough to see the error thrown this way.

Comment 4

2 years ago
Hi, do you still see this? I think I have changed the code around these places and this._prevActivityForFolder is a Map instead of an array/object.
I think this._prevActivityForFolder.get(x) should return 'undefined' if x was not found in the map. So the comparison to undefined should work.

Or have you found a case where prevItem is not undefined, but prevItem.eventID is ?
You need to log in before you can comment on or make changes to this bug.