My Opera is closing 1st of March

Covert Tomato

Spending CPU cycles associating random words

Debugging Yusef Applications

, , ,

Preemptive comment: this post inspiration comes from this forum thread.

Contrary to normal Unite applications, you may notice that whenever you try to debug a Yusef application using Dragonfly, you end up with the application crashing. On the javascript side, Opera complains about not being able to reshare (ALREADY_SHARED_ERR) some file, and the application will only accept to point you to some "static" section of the site, which won't work.

The problem, as stated by Antonio Afonso (thank you) is that Opera core won't clear some registered path when it reloads the unite application. However, Yusef magics involves sharing some resources under a static section right after running the application. To overcome this problem, I've hacked the Yusef core lib to allow debugging as described in the next section. However, some warnings first:

First warning: This fix works well for me. And it might work for you as well, although I definitely can't guarantee it. Use it at your own risks. If it kills your pets1, don't blame it on me!
Second warning: Newer versions of Yusef or Opera may have this fixed. Check them out!

The HackWorkaround

The problem lies with opera.io.webserver.sharePath: this function can't be called twice on a same path by design. Since Opera won't clear it's shared files on reload (hence, on Dragonfly debug), we need to explicitly do it.

Yusef offers the following wrapper around that sharePath function: function _shareDirectory( dir, exposedPath, rootPath ) in core.js. My hack is as follows (replacing the existing if block):
if( !(_config.sections.static+path in _staticFiles) )
{
  /* replace existing shares silently */
  opera.io.webserver.unsharePath( _config.sections.static+'/'+exposedPath+path, file );
  opera.io.webserver.sharePath( _config.sections.static+'/'+exposedPath+path, file );
}

Yusef fixed! Well... nearly: the ui plugin also uses sharePath to make application skins available. We can actually make it go through Yusef's wrapper, as suggested by the existing FIXME:
// FIXED: this should use Yusef.shareStaticDirectory when that function starts using sharePath instead of shareFile
Yusef.shareStaticDirectory(skin.resolve('public_html'), self.PLUGIN_PATH + '/' + skin.name + '/');


How do I debug Unite apps anyway?

First, make sure you know how to run Dragonfly; for starters, the debug menu is probably the easiest way to get it running. With the dragonfly window open, in the little dragonfly popup menu, select your unite app. It can be identified by its index2 page title, or if no title is specified by its url starting with "widget://".


From there, on the (left-side) Script tab, you can select which file you want to debug, add breakpoints, step in/over/out, just as in eclipse/visual studio. Great job, Opera, and many thanks to Chris Mills who made me aware of this JavaScript debugger (Me is clumsy! whistle)


  1. I did not actually test this code with every kind of pet to enforce safety.
  2. The actual index.html at the root of the app. Not the _index section handler.

Unite - Redirecting after form submissionSecurity Included: Using the ACL Plugin

Write a comment

New comments have been disabled for this post.