Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
fix a number of error conditions
bug: https://issues.apache.org/jira/browse/CB-284

invocation exception on WeinreClientEventsImpl.connectionCreated(): \
    TypeError: Cannot read property 'url' of undefined

The original problem logged in this issue was just one of the
problems fixed.  There were a handful of others.  Added
error checking where I could, and where I couldn't, I changed
the logger to not display a warning message (bug in Web Inspector).

Drive-by fixes for:

- changing the sequence number of channels to start at 1 instead
of a random number.  Note that the primary reason to use a
random number is to because the server can get confused
when you start/stop but have clients/targets that try to
reconnect with the same channel number.  Not a problem at all
in deployment, but a hassle at development time - or used to
be.  I'm going to try turning the 'random' off and see how
it goes.

- dump the pid at startup when in verbose mode; making it
easier to run top/dtrace/etc.
  • Loading branch information
pmuellr committed Feb 28, 2012
1 parent e455568 commit f4a798cfb08b28897a7aa75b0dbf874df77e9a0a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 18 deletions.
@@ -24,7 +24,7 @@ utils = exports
utils.Program = Program = path.basename process.argv[1]

SequenceNumberMax = 100 * 1024 * 1024
SequenceNumber = Math.floor(Math.random() * SequenceNumberMax)
SequenceNumber = 0

#-------------------------------------------------------------------------------
utils.getNextSequenceNumber = (g) ->
@@ -61,13 +61,14 @@ processOptions = (options, cb) ->

options.staticWebDir = getStaticWebDir()

utils.logVerbose "version: #{getVersion()}"
utils.logVerbose "option httpPort: #{options.httpPort}"
utils.logVerbose "option boundHost: #{options.boundHost}"
utils.logVerbose "option verbose: #{options.verbose}"
utils.logVerbose "option debug: #{options.debug}"
utils.logVerbose "option readTimeout: #{options.readTimeout}"
utils.logVerbose "option deathTimeout: #{options.deathTimeout}"
utils.logVerbose "pid: #{process.pid}"
utils.logVerbose "version: #{getVersion()}"
utils.logVerbose "option httpPort: #{options.httpPort}"
utils.logVerbose "option boundHost: #{options.boundHost}"
utils.logVerbose "option verbose: #{options.verbose}"
utils.logVerbose "option debug: #{options.debug}"
utils.logVerbose "option readTimeout: #{options.readTimeout}"
utils.logVerbose "option deathTimeout: #{options.deathTimeout}"

utils.setOptions options

@@ -25,6 +25,6 @@
# to determine whether to kill and restart the server.

cd `dirname $0`
supervisor -n -p 1 -e txt -w ../weinre.build/out/build-done.txt node weinre
supervisor -n -p 1 -e txt -w ../weinre.build/out/build-done.txt -- weinre $*

# supervisor: https://github.com/isaacs/node-supervisor
@@ -56,9 +56,10 @@ module.exports = class WeinreClientEventsImpl

#---------------------------------------------------------------------------
connectionCreated: (clientChannel, targetChannel) ->
if @client.uiAvailable()
WebInspector.panels.remote.setClientState clientChannel, "connected"
WebInspector.panels.remote.setTargetState targetChannel, "connected"
return if !@client.uiAvailable()

WebInspector.panels.remote.setClientState clientChannel, "connected"
WebInspector.panels.remote.setTargetState targetChannel, "connected"

return unless clientChannel == Weinre.messageDispatcher.channel

@@ -67,6 +68,8 @@ module.exports = class WeinreClientEventsImpl
WebInspector.panels.resources.reset()

target = WebInspector.panels.remote.getTarget(targetChannel)
return if !target

document.title = titleConnectedPrefix + target.url
WebInspector.inspectedURLChanged target.url

@@ -75,9 +78,10 @@ module.exports = class WeinreClientEventsImpl

#---------------------------------------------------------------------------
connectionDestroyed: (clientChannel, targetChannel) ->
if @client.uiAvailable()
WebInspector.panels.remote.setClientState clientChannel, "not-connected"
WebInspector.panels.remote.setTargetState targetChannel, "not-connected"
return if !@client.uiAvailable()

WebInspector.panels.remote.setClientState clientChannel, "not-connected"
WebInspector.panels.remote.setTargetState targetChannel, "not-connected"

return unless clientChannel == Weinre.messageDispatcher.channel

@@ -149,6 +149,12 @@ module.exports = class MessageDispatcher

#---------------------------------------------------------------------------
_handleMessage: (message) ->
skipErrorForMethods = [
'domContentEventFired'
'loadEventFired'
'childNodeRemoved'
]

try
data = JSON.parse(message.data)
catch e
@@ -176,7 +182,8 @@ module.exports = class MessageDispatcher
try
method.apply intf, args
catch e
Weinre.logError "weinre: invocation exception on #{methodSignature}: " + e
if methodName not in skipErrorForMethods
Weinre.logError "weinre: invocation exception on #{methodSignature}: " + e

if Verbose
Weinre.logDebug @constructor.name + "[#{@_url}]: recv #{intfName}.#{methodName}(#{JSON.stringify(args)})"
@@ -202,7 +202,8 @@ handleDOMNodeRemoved = (event) ->
return unless parentId

if targetId
Weinre.wi.DOMNotify.childNodeRemoved parentId, targetId
if parentId
Weinre.wi.DOMNotify.childNodeRemoved parentId, targetId
else
childCount = Weinre.nodeStore.childNodeCount(event.relatedNode)
Weinre.wi.DOMNotify.childNodeCountUpdated parentId, childCount
@@ -53,7 +53,7 @@ module.exports = class WiRuntimeImpl

#---------------------------------------------------------------------------
releaseWrapperObjectGroup: (injectedScriptId, objectGroup, callback) ->
result = Weinre.injectedScript.releaseWrapperObjectGroup(objectGroupName)
result = Weinre.injectedScript.releaseWrapperObjectGroup(objectGroup)
if callback
Weinre.WeinreTargetCommands.sendClientCallback callback, [ result ]

0 comments on commit f4a798c

Please sign in to comment.