Search code examples
javascriptdomscreen-scrapingxulrunner

javascript server under XULRunner fails


I'm trying to debug a DOM scraping packaged called crowbar. Anyhow, when I run I get:

Error: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIServerSocket.asyncListen]" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://crowbar/content/crowbar.js :: onLoad :: line 375" data: no]
Source File: chrome://crowbar/content/crowbar.js
Line: 375

Basically, asyncListen() is throwing NS_ERROR_NOT_INITIALIZED. This is weird because the line of code immediately before this is a call to init()! I've tried adding:

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

just before the call to asyncListen() and it had no effect. Is this a security issue? (btw, in case it matters, this is on a Fedora box, running as root, with selinux disabled)... I've also tried a few different port numbers...


Solution

  • Here's the source code: http://mxr.mozilla.org/mozilla-central/source/netwerk/base/src/nsServerSocket.cpp#369

    Are you sure init() doesn't fail (that's what initializes mFD)? Maybe something closes it before your call?

    I would build a debug XULRunner to build a debug version and/or try to get logging output from the app. Unfortunately, I can't figure out what the LOG() macro in that code resolves to, usually it's NSPR logging, but you have to guess the module name in order to enable logging for this module.

    Boris Zbarsky (one mozilla core developers) says:

    Since you're calling init(), the only other way I see to get an NS_ERROR_NOT_INITIALIZED out of asyncListen is for the thread you're running on to no longer be accepting events... So something odd is happening. Are there in fact multiple threads involved?